I am trying to add a row programatically using:
$("#grid").igGridUpdating("addRow", {"ID": 1, "Name": "John"});
$(
"#grid"
).igGridUpdating(
"addRow"
, {"ID": 1, "Name":
"John"
});
I am trying to set up a general function that allows me to pass down the grid ID and the column keys to add a new row.
function AddRow(GridName, Col1, Col2){ var Code = "CODE"; var Desc = "DESCRIPTION";
var myObj = {}; myObj[Col1] = Code; myObj[Col2] = Desc;
var json = JSON.stringify(myObj); console.log(json);
$(GridName).igGridUpdating("addRow", json);
}
I am creating an object using the Column keys as properties, and assigning the relevant values to them, then changing it to a Json string.
the log returns the correct format required by the "addRow" method:
{"Column1":"CODE","Column2":"DESCRIPTION"}
but this does not result in the correct row added to the grid. It adds a row with the value for the 2 columns being the first and second character of the above json string, ie { and " respectively.
Thanks,
That works perfectly.
Hello Hardik,
Thank you for using our igGrid.
addRow method expects object which is pairs of values in the format { column1Key: value1, column2Key: value2, ... }
http://help.infragistics.com/jQuery/2013.2/ui.iggridupdating#methods
So you need to pass myObj instead of json.
$(GridName).igGridUpdating("addRow", myObj);
Let me know if you need further assistance regarding this.