Automatically scroll jqgrid after loading data

I load jqgrid with approximately 100 rows of data. When the data finishes loading into jqgrid, I would like to automatically scroll through jqgrid so that the specific row is at the top. The top row will depend on the data loaded (for example: the first row containing the value "1" in the third column, etc.). Is there any way to do this?

thank

+3
source share
3 answers

I found a solution using gridComplete

gridComplete: function() {
    var ids = jQuery("#my_jqgrid").jqGrid('getDataIDs');
    for (var i = 0; i < ids.length; i++)
    {
      var current_id = ids[i];
      var row_data = $("#my_jqgrid").getRowData(current_id);
      if(row_data['status'] == '1')
      {
        var height = $("#"+current_id).attr('offsetHeight');
        var index = $("#dynamic_arrival_times").getInd(current_id);
        $(".ui-jqgrid-bdiv").scrollTop(height*index);
        return;
      }
    }
  }
+2
source

The cleanest way does this:

gridComplete: function() {
   $("#"+$('#GRID').jqGrid('getGridParam','selrow')).focus();
}
+5
source
gridComplete: function() {
    var gridScroll = $('div.ui-jqgrid-bdiv'); 
    gridScroll.scrollTop(gridScroll[0].scrollHeight - gridScroll.height());
}
+1
source

All Articles