jqgrid 过滤器在加载时删除一行一次
我使用 jqgrid 构建了一个网格,并且启用了过滤。检索到的数据类型是 json,我正在使用 loadonce 功能。当我应用一些过滤器时,它似乎总是隐藏在记录中。我使用网格寻呼机只是为了在网格上添加额外的按钮,并且我要删除网格寻呼机按钮(下一个、最后一个等)。我删除了寻呼机以查看是否存在任何冲突,但仍然遇到相同的错误。当网格加载时,我得到“View 1 - 7 of 7”并且我可以看到 7 条记录,当我应用过滤器时,输出是“View 1 - 3 of 4”。这意味着 4 条记录与过滤器匹配,但它只显示 3 条。现在,如果我清除过滤器,我会得到“查看 1 - 6 of 7”,同样缺少一条记录。我用 firebug 检查了表,看看记录是否被隐藏,但仍然没有。我尝试了 Firefox、Chrome、IE,在所有浏览器中我都遇到相同的错误。 jqgrid版本是4.1.1。有任何线索为什么会发生这种情况吗?
下面您可以看到代码:
jq($grid).jqGrid({
url: $url,
datatype: 'json',
mtype: 'Get',
colNames: colNamesList,
colModel: $colModel,
jsonReader : {
repeatitems:false,
id: "id",
},
rowNum: -1,
width: jq(document).width()-20,
height: 200,
pager: $pagerId,
viewrecords: true,
fixed: true,
shrinkToFit: false,
loadonce: true,
caption: $caption,
beforeRequest: function(){
if (!initialized) {
jq(blockElement).block({ message: '<h1 class="loadingMsg">Grid is loading, please wait...</h1>' });
}
},
loadComplete: function(data){
if (loadCompleteCallback != null){
loadCompleteCallback(data);
}
if (!initialized) {
jq.jGrowl('"' + $caption + '" Grid loaded.', {header:'Load Notification'});
jq(blockElement).unblock();
initialized = true;
}
}
});
if (!initialized) {
jq.jGrowl('"' + $caption + '" Grid loaded.', {header:'Load Notification'});
jq(blockElement).unblock();
initialized = true;
}
}
});
jq($grid).jqGrid('filterToolbar',{
stringResult: true,
searchOnEnter : false
});
提前致谢!
I constructed one grid using jqgrid and I have enabled filtering. The datatype retrieved is json and i'm using the loadonce feature. When I apply some filters it appears that it always hides on record. I'm using a grid pager just to have the extra buttons that i want to add on the grid and i'm removing the gridpager buttons (next, last, etc..). I removed the pager to see if there was any conflict but still i get the same error. When the grid loads i'm getting 'View 1 - 7 of 7' and i can see 7 records, when I'm applying a filter the output is 'View 1 - 3 of 4'. Which means that 4 records match the filter but it keeps displaying only 3. Now if i clear the filters i get 'View 1 - 6 of 7', again one record is missing. I checked the table with firebug to see if the record is hidden but still nothing. I tried firefox, chrome, IE and in all browsers i get the same error. The jqgrid version is 4.1.1. Any clues why this is happening?
Below you can see the code:
jq($grid).jqGrid({
url: $url,
datatype: 'json',
mtype: 'Get',
colNames: colNamesList,
colModel: $colModel,
jsonReader : {
repeatitems:false,
id: "id",
},
rowNum: -1,
width: jq(document).width()-20,
height: 200,
pager: $pagerId,
viewrecords: true,
fixed: true,
shrinkToFit: false,
loadonce: true,
caption: $caption,
beforeRequest: function(){
if (!initialized) {
jq(blockElement).block({ message: '<h1 class="loadingMsg">Grid is loading, please wait...</h1>' });
}
},
loadComplete: function(data){
if (loadCompleteCallback != null){
loadCompleteCallback(data);
}
if (!initialized) {
jq.jGrowl('"' + $caption + '" Grid loaded.', {header:'Load Notification'});
jq(blockElement).unblock();
initialized = true;
}
}
});
if (!initialized) {
jq.jGrowl('"' + $caption + '" Grid loaded.', {header:'Load Notification'});
jq(blockElement).unblock();
initialized = true;
}
}
});
jq($grid).jqGrid('filterToolbar',{
stringResult: true,
searchOnEnter : false
});
Thanks in advance!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我不明白以下内容:为什么你从服务器返回一行你不想显示的内容?删除服务器端已有的数据不是更容易吗?如果不可能,您可以删除
loadComplete
内的行。顺便说一句,在当前代码中,我看不到您在哪里设置自定义过滤器,该过滤器使网格的一行不可见。还有一点要注意:您永远不应该使用
rowNum: -1
。仅允许使用正值(例如rowNum: 10000
)。如果您使用loadonce: true
,这一点尤其重要,它会在第一次填充网格后将datatype
更改为'local'
。不允许使用负rowNum
。I don't understand the following: why you return from the server one row which you never want to show? Is it not easier to remove the data already on the server side? If it is not possible you can remove the row inside of
loadComplete
. By the way in the current code I can't see where you set custom filter which makes one row of the grid invisible.One more remark: You should never use
rowNum: -1
. Only positive values (likerowNum: 10000
) are permitted. It's especially important if you useloadonce: true
which chynges thedatatype
to'local'
after the first filling of the grid. The usage of negativerowNum
are not permitted.