问题
Version of Guriddo jqGrid JS: 4.7.0.
(function ($) {
'use strict';
$(function () {
$('#jqGrid').jqGrid({
url: '../StrictRoutesRebirth/StrictRoutes/',
mtype: 'GET',
datatype: 'json',
colModel: [{
label: 'id',
name: 'id',
hidden: false,
key: true
},
{
label: 'Примечание',
index: 'note',
name: 'note'
},
{
label: 'Логин',
index: 'userLogin',
name: 'userLogin',
hidden: true,
edittype: 'text'
}],
scroll: 1,
height: 500,
width: 500,
rowNum: 50,
rownumbers: true,
pager: '#jqGridPager',
prmNames: {
nd: null,
search: null,
page: 'page',
rows: 'pageSize',
sort: 'sortKey',
order: 'sortOrder',
totalrows: 'totalQty'
},
jsonReader: {
root: 'data.entries',
// page: 'data.pager.page',
total: 'data.pager.totalPages',
records: 'data.pager.totalQty'
}
});
});
})(jQuery);
When jqGrid meet the long text fields (that forth grid to render rows with big height) with enabled scroll: 1
jqGrid became to glitch and don't work. Attach screencast to show the problem.
回答1:
I wrote you in previous answers, that the current implementation of virtual scrolling have many restrictions. I wrote that I don't recommend to use the feature of jqGrid if it is really required.
The restriction which you describe in the question is very clear. You can examine the lines of jqGrid code to see that jqGrid get the outerHeight
of the first row (see the line) and multiply it on the number of rows (see the line and the line). Then one uses the result for the calculation of the number of new page which should be set after the scrolling.
So it's absolutely clear that one can't use virtual scrolling feature of jqGrid in case if one have different height for different rows.
There are a lot of other problems in the current implementation of virtual scrolling. The most important is the restriction of the number of rows which can be displayed in Internet Explorer. If you just open the page in Internet Explorer you will see only the first page of data and you will have no possibility to see more data and you will see no advice that displayed data are not all 20 rows which exist in the database. I find the problem much have as the problem which you described. So one try to use scroll: 1
option typically in case of large number of rows, but exactly in the case it works not. See the answer for the additional information.
If you examine exactly the documentation of jqGrid you will find many places (like here) that some features or some methods of jqGrid don't work with virtual scrolling. So if you would use scroll: 1
as your default feature then you will be not able to use many features of jqGrid.
来源:https://stackoverflow.com/questions/29162609/jqgrid-scroll-bug-with-big-rows