Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

jqGrid: All rows in "inline edit mode" by default

Tags:

jquery

jqgrid

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);
}
like image 720
CodeMad Avatar asked Feb 07 '12 02:02

CodeMad


1 Answers

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);
        }
    }
}
like image 64
Oleg Avatar answered Sep 18 '22 15:09

Oleg