Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Datatable server-side remember checkbox "selected"

Tags:

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?

like image 239
Erdi Avatar asked Jul 25 '16 05:07

Erdi


1 Answers

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.

like image 113
Gyrocode.com Avatar answered Sep 28 '22 02:09

Gyrocode.com