Datatable server-side remember checkbox "selected"

10,913

Although it's undocumented but stateSave option only works in client-side processing mode as far as I know.

Please see jQuery DataTables Checkboxes extension that provides universal solution for working with checkboxes in a table in both client-side and server-side processing modes.

For example:

var table = $('#example').DataTable({
   'processing': true,
   'serverSide': true,
   'ajax': '/your/script',
   'columnDefs': [
      {
        'targets': 0,
        'checkboxes': true
      }
   ],
   'order': [[1, 'asc']]
});

Alternatively, if you want to implement it yourself without a plug-in, see jQuery DataTables: Row selection using checkboxes article.

Share:
10,913
Erdi
Author by

Erdi

Web Developer ~

Updated on June 26, 2022

Comments

  • Erdi
    Erdi almost 2 years

    I have datatable server-side in modal(popup) to select item by select checkbox in item row.

    But when i change page, sorting, and search other item, my selected item in checkbox always reset or reload.

    Did datatable server-side can remember my selected checkbox? And if can, how to implement it in my case?

  • sadia
    sadia over 5 years
    I tried checkboxes with serverside processing using gyrocode.com/projects/jquery-datatables-checkboxes/examples/‌​… but whenever I checked any checkbox "select all" checkbox is marked as selected or ticked causes move to another page shows all selected records.
  • culter
    culter over 5 years
    @Gyrocode.com Do you have some example of server-side solution with checkboxes which are outside of table, please? Thanks
  • Gyrocode.com
    Gyrocode.com over 5 years
    @culter, not sure what you mean? Do you have an example? Share the link if you have posted a question on SO.
  • culter
    culter over 5 years
    Hi, Gyrocode, your example has checkboxes in front of every row, I needed to filter data in my table with checkboxes. E.g. when you click on one of the checkboxes, only rows with status 1 from colunn 3 are displayed and so on. But few days ago I was able to make it working. Anyway, thanks for reply.