Click here to Skip to main content
15,889,834 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hello,

I have bind records in table and applied paging in MVC View. I have checkbox(checkbox id is pID) in it. when I select some of the record in first page and click on paging and select some records in other page then previous page selected records got deselected.

I am using below code to get selected check box pIDs but when click on paging it gets overwrite.

$.map($('input[name="Contractors"]:checked'), function (c) { return c.value; });


Thanks,

What I have tried:

I tried with below code but it overwrites with other page selection.

$.map($('input[name="Contractors"]:checked'), function (c) { return c.value; });
Posted
Updated 23-Mar-17 23:21pm

Actually you have to store those selection when you click on next page. Use localstorage, cookie or something to store the ids. When you come back to the page, try to select those ids again.
 
Share this answer
 
Thanks,

For the reply but I googled and I got the solution.

var str = [];
    function selectContractors(pID) {
        var test = $.map($('input[id="'+pID+'"]:checked'), function (c) { return c.value; });
        //debugger;
        if(test.length > 0)
        {
            str.push(pID);
        }
        else
        {
            str.splice(str.indexOf(pID),1);
        }
}
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900