JQGRID - 维护复选框选择状态 - 页面刷新/重定向/重新加载 [英] JQGRID - maintain check box selection state - page refresh / redirect / reload

查看:46
本文介绍了JQGRID - 维护复选框选择状态 - 页面刷新/重定向/重新加载的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

H如何在页面刷新/重新加载/从 JQGRID 中的其他页面重定向后保持复选框选择.

我在 aspx 页面上工作.

能够使用以下代码在分页中保持复选框选择状态:

 gridComplete: function () {var currentPage = $(this).getGridParam('page').toString();//检索此页面以前存储的任何行并重新选择它们varretrieveSelectedRows = $(this).data(currentPage);如果(检索SelectedRows){$.each(retrieveSelectedRows, function (index, value) {$('#list').setSelection(value, false);});}},onPaging:功能(一){var pagerId = this.p.pager.substr(1);//ger paper id 像pager"var pageValue = $('input.ui-pg-input', "#pg_" + $.jgrid.jqID(pagerId)).val();var saveSelectedRows = $(this).getGridParam('selarrrow');//存储任何选定的行$(this).data(pageValue.toString(), saveSelectedRows);}

但是,如何JQGrid页面刷新/重定向/重新加载中保持复选框选择状态?

另外,我在 Window.OnLoad 上尝试了以下代码,但它不起作用

$("#list").trigger("reloadGrid", [{page: 1, current: true}]);

解决方案

在旧版本的 jqGrid 中,对网格的多个页面进行选择的实现非常棘手.我发布了答案回答(尝试演示)和相应的实现.

另一方面,在多个页面上选择多行的情况非常普遍.因此我在免费的 jqGrid 中实现了新功能.现在可以将新的 multiPageSelection: true 选项与 multiselect: true 结合使用.它通过以下方式改变选择的行为:

  • 可以在创建网格时直接使用selarrrow数组预选一些行.
  • 数组selarrrow 可以保存来自其他 页面的行的id.更改页面时不会清除数组 selarrrow.如果 jqGrid 的 rowid 在数组 selarrrow 中,则它只选择行.
  • 点击复选框列标题中的全选"复选框,用all本地data的rowids填充selarrrow(来自所有页面)

演示演示了新功能.>

How to maintain the checkbox selection after the page refresh / reload / redirected from some other page in JQGRID.

I am working in aspx pages.

I am able to maintain the checkbox selection state in paging using following code:

    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) {
        $('#list').setSelection(value, false);
     });
    }
   },
   onPaging: function (a) {
     var pagerId = this.p.pager.substr(1); // ger paper id like "pager" 
     var pageValue = $('input.ui-pg-input', "#pg_" +           $.jgrid.jqID(pagerId)).val();
     var saveSelectedRows = $(this).getGridParam('selarrrow'); //Store any selected rows 
     $(this).data(pageValue.toString(), saveSelectedRows);
  }

But, how to maintain the checkbox selection state in page refresh / redirect / reload in JQGrid ?

Also, I tried the following code on Window.OnLoad, but it is not working

$("#list").trigger("reloadGrid", [{page: 1, current: true}]);

解决方案

The implementation of selection over multiple pages of the grid is very tricky in old versions of jqGrid. I posted the answer, the answer (try the demo) with the corresponding implementations.

On the other side the scenario of selection of multiple rows over multiple pages is very common. Thus I implemented new feature in free jqGrid. Now one can just use new multiPageSelection: true option in combination with multiselect: true. It changes the behavior of selection in the following way:

  • one can use selarrrow array to pre-select some rows directly during creating the grid.
  • the array selarrrow can hold the ids of rows from other pages. The array selarrrow will be not cleared on changing the page. jqGrid just select rows if it's rowid is in the array selarrrow.
  • click on "Select All" checkbox in the header of checkbox columns fills selarrrow with all rowids of local data (from all pages)

The demo demonstrates the new feature.

这篇关于JQGRID - 维护复选框选择状态 - 页面刷新/重定向/重新加载的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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