I'm trying to add an item to my data source, and then re-load the grid based on this answer. The grid loads fine. The addItemToGrid
gets called a few times, and I'm verifying that the underlying tableSrc object is getting added to, but the grid remains unchanged.
var tableSrc = { "rows": [
{ "title": "Title1", "subtitle": "subTitle", "authors": ["a1", "a2", "a3"] },
{ "title": "Title2", "subtitle": "subtitle", "authors": ["X", "Y"] },
{ "title": "Title3", "subtitle": "subTitle", "authors": ["1", "2", "3", "4"]}]
};
targetGrid = $("#jqGridElement").jqGrid({
datastr: tableSrc,
jsonReader: { repeatitems: false },
datatype: "jsonstring",
colNames: ['title', 'subtitle'],
colModel: [
{ name: 'title', index: 'title', width: 55 },
{ name: 'subtitle', index: 'subtitle'}],
height: 'auto',
gridview: true
});
function addItemToGrid() {
tableSrc.rows.push({ "title": "NEW", "subtitle": "HELLO", "authors": ["1", "2", "3", "4"] });
$("#jqGridElement").trigger('reloadGrid');
//$("#jqGridElement").jqGrid('reloadGrid');
}