Reaching unmatched rows data after search

Reaching unmatched rows data after search

furkanekincifurkanekinci Posts: 3Questions: 1Answers: 0

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

  • kthorngrenkthorngren Posts: 20,269Questions: 26Answers: 4,765

    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 like cells().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

  • furkanekincifurkanekinci Posts: 3Questions: 1Answers: 0

    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?

  • kthorngrenkthorngren Posts: 20,269Questions: 26Answers: 4,765
    Answer ✓

    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

  • furkanekincifurkanekinci Posts: 3Questions: 1Answers: 0

    Dear Kevin, thank you so much for your helps. You example solved my problem. Best regards.

Sign In or Register to comment.