Checkbox with AJAX Datatables

Checkbox with AJAX Datatables

techguy1988techguy1988 Posts: 27Questions: 0Answers: 0
edited November 2011 in General
Hi,

I've got a bit of a problem with the AJAX data tables, what I am trying to do is I have a load of checkboxes but obviously when I press next/back it looses the "checked" state of the checkbox (as it is AJAX).

Could anyone advise me the best way of the best way to do this? When clicked on the checkbox would it be a good idea to put it in a session or something?


P.S. Datatables are great, I look forward to using them in every system I build! Good job allan!



Thanks.

Replies

  • fbasfbas Posts: 1,094Questions: 4Answers: 0
    does each row have a unique id? add that id to a javascript array. if they un-check a checkbox, make sure to remove it from the array.

    note: PHP session variables are only useful for storing data between pages, not on a single page with dynamic content, so you'll want to use a javascript solution.
  • techguy1988techguy1988 Posts: 27Questions: 0Answers: 0
    Hi Fbas,

    Yeah each row has a uniqueID, my problem is when I use the paging it looses the checked, checkbox!
  • mbouclasmbouclas Posts: 3Questions: 0Answers: 0
    If you plan on doing it like gmail, i.e persistent, you can use a cookie solution. Store your ids inside a cookie and bind the next/prev click to a function that checks the cookie. If you prefer HTML 5 has local storage which works great in your case. So, when prev/next is clicked, JQ will go to your prefered method of storage, retreive the ids and render the checkboxes.
    If you're interested on what happens on the one page alone, setup an array and do a look up after prev/next is pressed.
This discussion has been closed.