-1

This is my setup code for the grid.

var source =
{
    datatype: "json",
    datafields: [
        { name: 'Name', type: 'string' },
        { name: 'PaymentSchemeName', type: 'string' },
        { name: 'IsActive', type: 'boolean' },
        { name: 'Remarks', type: 'string' }
    ],
    url: "@Url.Action("GetParkades")"
};
var dataAdapter = new $.jqx.dataAdapter(source);
$("#index-grid").jqxGrid(
    {
        width: 900,
        source: dataAdapter,
        editable: true,
        columns: [
            { text: "Name", datafield: "Name", cellsformat: 'd', width: 300 },
            { text: "Payment Scheme", datafield: "PaymentSchemeName", width: 200 },
            { text: "Active", datafield: "IsActive", width: 50, columntype: 'checkbox' },
            { text: "Operator Remarks", datafield: "Remarks" }
        ]
    });
$("#addrowbutton").jqxButton({ theme: theme });
$("#addrowbutton").bind('click', function() {
    var id = $("#index-grid").jqxGrid('getdatainformation').rowscount;
    $("#index-grid").jqxGrid('addrow', id, []);
});

The click event for addrowbutton fires proplerly, and the line $("#index-grid").jqxGrid('addrow', id, []); seems to execute with no error, but no new row is appended to the grid. I seem to be missing a config or line of code somewhere. What could it be?

ProfK
  • 49,207
  • 121
  • 399
  • 775

3 Answers3

0

May be it should be {} instead of [].

scripto
  • 2,297
  • 1
  • 14
  • 13
0

It should be {}... and you dont need second arg as the row is added at the end I believe. Here is some code I used to add a row...

$('#jqxGrid').jqxGrid('addrow', null, {});
// JQX doesn't scroll to the page, so do it ourselves..
var value = $('#jqxGrid').jqxGrid('getrows').length;
$('#jqxGrid').jqxGrid('ensurerowvisible', value);
Lol
  • 940
  • 8
  • 6
0

Add this code block in var source={}

addrow: function (rowid, rowdata, position, commit) {
commit(true);
}

You need to commit the row to make addition complete.

Krish
  • 21
  • 4