Jquery – jqGrid: All rows in “inline edit mode” by default

jqgridjquery

I have a jqGrid where a row is editable on click (i.e. 'editRow' inside 'OnSelectRow' works fine). But my requirement is to "load the grid with ALL ROWS IN EDIT MODE by default (Inline edit)", so there should not be any need for me click individual rows. Can someone throw some lights on?

I tried the below code but didnt work

var data_val = myGrid.getRowData();
for (var i=0;i<data_val.length;i++)
{
myGrid.editRow(data_val[i], true);
}

Best Answer

You have to enumerate all rows of grid and call editRow for every row. The code can be like the following

loadComplete: function () {
    var $this = $(this), ids = $this.jqGrid('getDataIDs'), i, l = ids.length;
    for (i = 0; i < l; i++) {
        $this.jqGrid('editRow', ids[i], true);
    }
}

or the following

loadComplete: function () {
    var $this = $(this), rows = this.rows, l = rows.length, i, row;
    for (i = 0; i < l; i++) {
        row = rows[i];
        if ($.inArray('jqgrow', row.className.split(' ')) >= 0) {
            $this.jqGrid('editRow', row.id, true);
        }
    }
}
Related Topic