views:

162

answers:

4

Hello All,

This is the code that i use to find whether any checkbox is checked in gridview

 if($("table tr td:first-child input:checkbox:checked").length ==0)
 {
     alert("Select atleast one event to delete");return false ;
 }

 if(confirm('Are you sure! you want to delete the selected events(s)?'))
     return true;
 else
     return false ;

i select a checkbox in the first page and i navigate to the 2nd page and i click "Delete", it throws "select atleast one Channel to delete". Which Shouldn't!

Without paging it works fine. Any insight to implement this with paging?

A: 

As soon as you navigate to the next page the DOM elements for the checkboxes selected first are not displayed anymore, and therefore the script will not know about them.

You will need to cache the state at a page change if you wish to preserve the checkbox state through pages. Remember that these won't be passed in a postback either.

Tim
A: 

This is because the checkboxes in the first page are not rendered when the second page is shown.

It would be better when doing critical actions like deleting records the user be aware of which all records are being deleted.

The issue with your approach is that the user won't be able to find the records which are selected for action if he is in another page. So it won't be a good usability feature in my opinion.

rahul
Even i travel in the same boat saying this approach isn't a good feature but CUSTOMER goes in his own way! So looking out for this to get implemented!
Sri Kumar
A: 

Instead of checking checkbox checked value , try saving them in session or something and try looping through them and check for those values. May be store them in somekind of array. Above users are right , when you dont have control rendered on the screen , you will get object null error.

Ved
A: 

You can manually maintain status of checked checkboxes in javascript while moving from one page to other.

And on final delete method, check for the any checked value in your available status data.

Krunal