简体   繁体   中英

Datatable server-side remember checkbox “selected”

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?

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM