Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
25
igGrid updating "addRow" - using json string to add a row
posted

I am trying to add a row programatically using:

$("#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.