Callback for When does jqGrid complete reload?

I am using the jqGrid plugin and at some point I need to update the grid and set the selected row to match the entry I show in detail in another section of the page. I have the following code, but it doesn't work:

$("#AllActions").trigger("reloadGrid").setSelection(selectedRow);

      

The selected Row parameter comes from an event handler that is called when the data changes and the grid is refreshed.

I'm sure the problem is that the grid is not loading when setting the selection, because if I find an alert () call between trigger () and setSelection () calls, it works.

I would be grateful for any advice.

[Edit] Looks like jqGrid's setSelect doesn't work after reloadGrid is linked but hasn't got permission. [/ Edit]

+2


a source to share


2 answers


Of all, you have to store the rowid of the old selection in a variable, then call $("#AllActions").trigger("reloadGrid")

and inside the selection an event handler loadComplete

with respect to $("#AllActions").setSelection(rowid)

.



Don't forget to set the scrollrows:true

jqGrid option to make sure the selected row is visible.

+5


a source


Try it, I did it and it works.

setTimeout("$('#grid').jqGrid('setSelection','"+id+"')", 1000); 

      



and of course in the main grid configuration. You can use somthing like this

onSelectRow: function(ids) { 
  if(ids == null) { 
    ids=0; 
    if($("#grid-detail").jqGrid('getGridParam','records') >0 ) { 
        $("#grid-detail").jqGrid('setGridParam',{url:"server.php?&grid=1&oper=get_records&id=&id="+ids,page:1}); 
        $("#grid-detail").jqGrid().trigger('reloadGrid'); 

    } 
  } else { 
        var arr = jQuery("#list-maestro").getRowData( ids );
        var id = arr.id; 
        $("#grid-detail").jqGrid('setGridParam',{url:"server.php?&grid=1&oper=get_records&id="+id,page:1}); 
        $("#grid-detail").jqGrid().trigger('reloadGrid'); 
  }
}

      

+1


a source







All Articles