• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Maintaining the state of checkbox in pagination

 
Ranch Hand
Posts: 41
Netscape Safari Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello Ranchers,

I have retrieved 10 records/page along with the check boxes in front of each records from the database and also done pagination in it.

The problem i am getting is whenever i select the check box and go to 2nd page and again come back on previous 1st page , the check box state is refreshed and i do not see any checked check boxes.

How can i maintain the state of a check box in pagination??


 
Author
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
We have no idea how you're implementing your pagination, whether or not you're going back to the server when you return to a previous page, how the initial state of the checkboxes is determined in the first place, etc.

If you're talking about this:

1) I hit the database and get the first page's results
2) I check some checkboxes
3) I click on the next page and go to the server to get page two
4) I click some checkboxes there as well
5) I click to go back to page one and the boxes I checked are no longer checked

then the problem is obvious: the checkboxes aren't being persisted, and the page is being refreshed, so of course their values are re-initialized. You'd need to either persist the changes when you go to the next page, or Ajax an update when a checkbox state changes, or...

If you're doing the pagination "in-place", i.e. just updating the pagination div, you *could* keep the checkbox states in JavaScript and update them in one shot when you submit the changes.

But with the information given, it's difficult to help.
 
Manish Sahni
Ranch Hand
Posts: 41
Netscape Safari Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi David ,

I am talking about exactly this:-


1) I hit the database and get the first page's results
2) I check some checkboxes
3) I click on the next page and go to the server to get page two
4) I click some checkboxes there as well
5) I click to go back to page one and the boxes I checked are no longer checked

How to persist the changes in checkbox?? any link or help would be appreciable.
 
Ranch Hand
Posts: 152
Eclipse IDE Chrome Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi manish,
just store the id's of selected checkboxes in a hidden field as a comma separated value.
hope this helps
 
Ranch Hand
Posts: 65
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If you save the state of check box when user move to page two.
then restore the saved state, when user moves back to the page one.
But
if user move to the page three
then your requirement says you have to save the state of check boxes of both previous pages. ?
if it is so
then you have to decide the depth up to which you maintains that?
Other factor can be like correctness to check the same boxes whose states you have saved
because if records modified ?
take care for these steps.
 
Never trust an airline that limits their passengers to one carry on iguana. Put this tiny ad in your shoe:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic