jqGrid multiselect,移至下一页时,选中框保留 [英] jqGrid multiselect, checked-box persist when move to the next page

查看:189
本文介绍了jqGrid multiselect,移至下一页时,选中框保留的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果您看到jqGrid演示:

http://www.trirand.com/blog/jqgrid/jqgrid.html

部分:高级->多项选择

当我移至下一页时,您将看到选中的复选框未保留,并且 再次返回上一页.

如何使其持久?

这是我的情况,在我的应用程序中,我可以使用一组功能 添加几个客户,我正在使用jqgrid来显示数千个客户.

我要检查我想要的每个客户,然后提交此选定的客户并将其添加到指定的组中..

我该怎么做? (使jqgrid,multiselect持久吗?)

谢谢.

解决方案

使用gridComplete和onPaging事件以及jquery .data()方法非常简单.这比我在网上看到的很多东西要简单得多,所以我想分享一下.我的网格的选择器是"#employeerolegrid".

       gridComplete: function () {

            var currentPage = $(this).getGridParam('page').toString();

            //retrieve any previously stored rows for this page and re-select them
            var retrieveSelectedRows = $(this).data(currentPage);
            if (retrieveSelectedRows) {
                $.each(retrieveSelectedRows, function (index, value) {
                    $('#employeerolegrid').setSelection(value, false);
                });
            }
        },
        onPaging: function () {
            var saveSelectedRows = $(this).getGridParam('selarrrow');
            var page = $(this).getGridParam('page') - 1;

            //Store any selected rows
            $(this).data(page.toString(), saveSelectedRows);
        }

If you see jqGrid demo :

http://www.trirand.com/blog/jqgrid/jqgrid.html

Section : Advanced --> Multiselect

You'll see that the checked checkbox is not persist when i move to the next page, and back to the previouse page again ..

How to make it persist ?

It's my scenario, in my applications there is a group functionality where i can add several customer, i'm using jqgrid to display thousands of customers.

I want to check every customer i want, and then submit this selected customer and add it to the specified group ..

How can i do this ? (make jqgrid, multiselect persist ?)

Thanks.

解决方案

This is fairly simple to do using the gridComplete and onPaging events plus the jquery .data() method. This is much simpler than a lot of the stuff I've seen floating around the net, so I thought I'd share it. The selector for my grid is '#employeerolegrid'.

       gridComplete: function () {

            var currentPage = $(this).getGridParam('page').toString();

            //retrieve any previously stored rows for this page and re-select them
            var retrieveSelectedRows = $(this).data(currentPage);
            if (retrieveSelectedRows) {
                $.each(retrieveSelectedRows, function (index, value) {
                    $('#employeerolegrid').setSelection(value, false);
                });
            }
        },
        onPaging: function () {
            var saveSelectedRows = $(this).getGridParam('selarrrow');
            var page = $(this).getGridParam('page') - 1;

            //Store any selected rows
            $(this).data(page.toString(), saveSelectedRows);
        }

这篇关于jqGrid multiselect,移至下一页时,选中框保留的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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