jqGrid:如何在不同页面上使用多重选择 [英] jqGrid: How to use multiselect on different pages

查看:106
本文介绍了jqGrid:如何在不同页面上使用多重选择的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

一个简单的问题,很难找到答案:

Simple question, hard to find an answer:

如果我尝试以编程方式选择行,则使用以下方法:

If I try to select a row programmatically, I use this:

$('#grid').jqGrid('setSelection', rowId);

问题在于它仅选择当前可见页面上的行.如果 rowId 在另一页上,则不会选择它.

The problem is that it only selects rows on current visible page. If rowId is on another page, it will not be selected.

更多信息:我的目标是在首次加载页面时选择多行(分布在多页上).

More info: My goal is to select multiple rows (spread on multiple pages) when page loads for the first time.

谢谢, 拉斐尔

PS:这个人有同样的问题.尚无答案: jqgrid multiselect仅选择行当前页面(如果启用了分页).如何使其跨页面选择行?

PS: This guy has the same problem. No answer yet: jqgrid multiselect only selects rows on the current page, if paging is enabled. How to make it select rows across pages?

推荐答案

对,jqGrid将仅选择当前页面上的行.为了选择其他行,您需要维护一个选定ID的列表并手动选择它们.

Right, jqGrid will only select rows on the current page. In order to select other rows you need to maintain a list of selected ID's and manually select them.

为此,您需要向loadComplete事件中添加代码以搜索当前页面并选择以下任意行:

To do this you need to add code to your loadComplete event to search the current page and select any of these rows:

var ids = grid.jqGrid('getDataIDs');
for (var i = 0; i < ids.length; i++){
    if (selected[ids[i]] === true ){
        grid.setSelection(ids[i], false);
    }
}

当用户选择/取消选择行时,还需要向onSelectRowonSelectAll事件中添加代码以调整selected的内容:

You also need to add code to your onSelectRow and onSelectAll events to adjust the contents of selected when the user selects/unselects rows:

onSelectRow: function(rowid, status){
    selected[rowid] = status;
    setSelectedDeviceCount();
},

onSelectAll: function(rowids, status){
    for (var i = 0; i < rowids.length; i++){
        selected[rowids[i]] = status;
    }
}

有帮助吗?

这篇关于jqGrid:如何在不同页面上使用多重选择的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆