jqGrid rowNum选项问题 [英] jqGrid rowNum option issue
问题描述
假设在navgrid中行号从10更改为30,并且我们按如下方式处理onPaging:
Assume that row numbers is changed from 10 to 30 in navgrid and that we handle onPaging like so:
...
onPaging: function(pgbtn) {
var rowNum = $(this).getGridParam('rowNum');
return 'stop';
}
- 在jqGrid 4.4.0中,rowNum为30.
- 在jqGrid 4.7.0中,rowNum为10.
这是预期的行为,因为我认为rowNum应该为30?
Is this expected behaviour because I think rowNum should be 30?
推荐答案
执行顺序更改为(比较该行在jqGrid 4.4.0中). jqGrid首先在jqGrid 4.4.0中更改了rowNum``and then called
onPaging`,但在jqFeid 4.7.0中更改了内容.
The order of the execution is changed in (compare the line in jqGrid 4.7.0 with the line in jqGrid 4.4.0). jqGrid first changed the rowNum``and then called
onPaging` in jqGrid 4.4.0, but in jqFeid 4.7.0 the oder is changed.
要访问新的rowNum
值,应直接从相应的<select>
控件中获取rowNum
的值.如果使用网格底部的pager
,则相应的代码可能如下:
To access to the new value of rowNum
one should get the value of rowNum
from the corresponding <select>
control directly. If you use the pager
at the bottom of the grid then the corresponding code could be the following:
onPaging: function (pgButton) {
var p = $(this).jqGrid("getGridParam"),
newRowNum = parseInt($(p.pager).find(".ui-pg-selbox").val());
if (...) { // some stop criteria
return "stop";
}
}
如果使用toppager: true
选项,则jqGrid在网格顶部创建寻呼机,然后将toppager
参数的值从true
更改为寻呼机的选择器ID.因此,您可以使用类似
If you use toppager: true
option then jqGrid create the pager on the top of the grid and then it change the value of toppager
parameter from true
to the selector id of the pager. So you can use the code like
onPaging: function (pgButton) {
var p = $(this).jqGrid("getGridParam"),
newRowNum = parseInt($(p.toppager).find(".ui-pg-selbox").val());
if (...) { // some stop criteria
return "stop";
}
}
,仅在上一个代码示例中使用p.toppager
代替p.pager
.
which just use p.toppager
instead of p.pager
in the previous code example.
如果同时使用 顶部和底部寻呼机,则必须同时获得两个值并选择不等于rowNum
参数值的值:
In case of usage both top and bottom pagers you have to get both values and choose the value which is not equal to the value of rowNum
parameter:
onPaging: function (pgButton) {
var p = $(this).jqGrid("getGridParam"),
rowNumBottom = parseInt($(p.pager).find(".ui-pg-selbox").val()),
rowNumTop = parseInt($(p.toppager).find(".ui-pg-selbox").val()),
newRowNum = p.rowNum === rowNumTop ? rowNumBottom: rowNumTop;
if (...) { // some stop criteria
return "stop";
}
}
在寻呼机中进行其他更改后调用onPaging
时,例如,如果用户在输入框中输入了新的寻呼机编号的新值,则存在关闭问题.
By the way there are exist close problem in case of calling onPaging
after other changing in the pager, for example if the user typed new value in the input box with new pager number.
我现在正在我的叉子上以我的叉子的github.我更改jqGrid的代码,以便onPaging
接收第二个参数,该参数是具有属性newPage
,currentPage
,lastPage
,currentRowNum
和newRowNum
的对象.相应的jQuery事件jqGridPaging
也被添加.此外,我已经更改了第一个参数的值,以使其对应 the文档,如果用户单击相应的寻呼机按钮,则该值为字符串"first"
,"last"
,"prev"
或"next"
.实际上,版本4.7使用的是相应寻呼机按钮的id
而不是"first"
,"last"
,"prev"
,"next"
.因此,字符串"first"
,"last"
,"prev"
,"next"
可以附加"_"
和寻呼机(或toppager)的ID.
I'm developing now free jqGrid as my fork on github. I change the code of jqGrid so that onPaging
receives the second parameter which is object with the properties newPage
, currentPage
, lastPage
, currentRowNum
and newRowNum
. The corresponding jQuery event jqGridPaging
are added too. Moreover I have changed the value of the first parameter so that it corresponds the documentation and the value will be the string "first"
, "last"
, "prev"
or "next"
in case when the user clicked on the corresponding pager button. The version 4.7 used in reality the id
of the corresponding pager buttons instead of "first"
, "last"
, "prev"
, "next"
. So the strings "first"
, "last"
, "prev"
, "next"
could be appended with "_"
and the id of the pager (or toppager).
因此,可以直接在回调代码中使用options.newRowNum
或options.currentRowNum
:
Thus one can just use options.newRowNum
or options.currentRowNum
directly in the code of callback:
onPaging: function (pgButton, options) {
// one can use options.newRowNum directly
// the value options.currentRowNum is identical to
// $(this).jqGrid("getGridParam", "rowNum")
if (...) { // some stop criteria
return "stop";
}
}
这篇关于jqGrid rowNum选项问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!