Bootstrap table multi-marquee paging retention

Source: Internet
Author: User

When using the check box function of bootstrap table, because of the service end paging, when the first page selected some data, and then click on the second page to select some data, again point to the first page, found that the original selected data has been emptied, the original multi-box does not support paging to retain the multi-selection data.

Solution: At the time of paging, the original selection of the data is saved with a global variable, when the page back again, to determine whether the current data exists in the data in the saved array, the presence of the state is selected. Of course, when you deselect it, delete the corresponding data in the array.

To solve this problem, check the documentation on GitHub to find out someone raised the issue, and author Wenzhixin also wrote a corresponding example to show, want to see the original problem click Open link.

Click to open the link to see the example directly

The original example is a table that is implemented in HTML and uses service-side paging. and the relevant JS method is not perfect, I also stepped on a lot of pits, so this blog in the original author of the example written on the basis of the relevant changes, in this show and explain:



[javascript]  View plain  copy var  $table;   var selectionids = [];   //Save selected ids   $ (function  ()  {        $table  = $ (" #example1 "). Bootstraptable ({           contenttype:" Application/x-www-form-urlencoded; charset=utf-8 ",      //initialization code             url: ' <%=basepath%>/order/queryorderlist ',            method:  ' Post ',            striped:true,           //odd-even line fade-color table             pagination:true,         //Display Paging            clickToSelect:true,      //Check whether            maintainSelected:true,            sidePagination:  "Server",     //service-side paging            idfield: "id",            pageSize: 10,           responsehandler: responsehandler, //the method that is executed before the page data is rendered, this configuration is important!!!!!!!            columns: [                {field:  ' CheckStatus ',checkbox: true},   //assigns a field value of "CheckStatus" to the marquee to change the selection state!!!!!                {field:  ' id ', visible: false},                {field:  ' OrderNumber ', Title:&nbsP; " Order number ", align: ' center ', Width: ' 10% '}           ]       });       //Select event Action Array         Var union = function (array,ids) {           $. Each (ids, function  (i, id)  {                if ($.inarray (Id,array) ==-1) {                    array[array.length] = id;                }                 });                return array;       };        //CancelSelect event Action Array        var difference = function (array,ids) {               $.each (ids, function  (i,  id)  {                     var index = $.inarray (Id,array);  

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.