Reaching unmatched rows data after search
Reaching unmatched rows data after search
There is a table with rows, each row has own checkbox. All checked data information appears in summary section.
After all check event, all checkboxes status are checking and summary being updated. If user uses search feature, datatable removes all unmatched rows tr elements from html and we can not get unmatched rows checkboxes status so lost real data till search box clean.
Is it possible to change search feature behaviour? For example; instead of removing tr elements, adding display:none could help us.
This question has an accepted answers - jump to answer
Answers
The core behavior of Datatables is to place only the rows in the DOM that are being displayed. Datatables keeps a data cache with all the data. So there is no option to use
display:none
. However Datatables provides APIs likecells().nodes()
,column().nodes()
,row().nodes()
, etc to get to the DOM elements. You will need to adapt your code to use the relevant API for your situation.If you provide a link to your page or a test case replicating what you are doing we can provide more specific help.
https://datatables.net/manual/tech-notes/10#How-to-provide-a-test-case
Kevin
Hi Kevin, thank you for your quick interaction. I checked your pointed APIs but confused little bit. Here is a live test.
http://live.datatables.net/yuzeyuro/2/
Before search, check some of checkboxes then click Get Checked Count and get the value. It is correct.
Then search something, try to hide some checked checkboxes by search keyword, then click the button again. You will get only visible rows checked checkboxes count, whereas total data actually has more checked checkboxes.
Could I be overlooking something?
I opted to use
cells().nodes()
to get the nodes for column 0.. This is pulled from the Datatables cache not the DOM since only the rows being displayed are in the DOM Used the result as part of the jQuery selector for your loop.http://live.datatables.net/dowuloje/1/edit
Kevin
Dear Kevin, thank you so much for your helps. You example solved my problem. Best regards.