I am loading a jqgrid with approximately 100 rows of data. When the data is finished loading into the jqgrid, I would like to automaticall开发者_运维百科y scroll the jqgrid so that a certain row is at the top. The top row will depend on the loaded data (ex: the first row that contains the value "1" in the 3rd column, etc). Is there any way to do this?
Thanks
The cleanest way is doing this:
gridComplete: function() {
$("#"+$('#GRID').jqGrid('getGridParam','selrow')).focus();
}
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;
}
}
}
gridComplete: function() {
var gridScroll = $('div.ui-jqgrid-bdiv');
gridScroll.scrollTop(gridScroll[0].scrollHeight - gridScroll.height());
}
精彩评论