The addRow method requires a values object to pass in.
But using the default add-new-row from the grid UI, the default value is loaded automatically when clicking the cell for adding new row.
Is there a way that the defaultValue set from the columnSettings can be loaded automatically when adding new row from the addRow method?
Thanks.
Hi Erica,
You can easily implement a function which creates an object from the columnSettings default values. Then use this object to add additional information and pass it to addRow method.
Here is an example implementation of such method:
function getDefaultValuesObject() { var tmpObject = {}; var colSettings = $("#grid1").igGridUpdating("option", "columnSettings"); colSettings = colSettings || []; for (var i = 0; i < colSettings.length; i++) { if (colSettings[i].hasOwnProperty("defaultValue")) { tmpObject[colSettings[i].columnKey] = colSettings[i].defaultValue; } } return tmpObject; }
function getDefaultValuesObject() {
var tmpObject = {};
var colSettings = $("#grid1").igGridUpdating("option", "columnSettings");
colSettings = colSettings || [];
for (var i = 0; i < colSettings.length; i++) {
if (colSettings[i].hasOwnProperty("defaultValue")) {
tmpObject[colSettings[i].columnKey] = colSettings[i].defaultValue;
}
return tmpObject;
Best regards,
Martin Pavlov
Infragistics, Inc.