SearchPanes and search plugins

SearchPanes and search plugins

kthorngrenkthorngren Posts: 21,322Questions: 26Answers: 4,948
edited February 2020 in SearchPanes

I'm working on a search plugin to filter duplicate data from the visible rows. If I use the search input I see that the plugin is executed once for each visible row when using draw(). However if I use SearchPanes to filter the table then the plugin is executed once for each row, visible or not, in the table when using draw().

Is this expected behavior with SearchPanes?

Is there a way in the search plugin to know if the row is visible so I know with to ignore it or use it when checking for duplicates? Or a way to know Search Panes performed the draw to skip the plugin altogether?

Do you want a test case?

Kevin

This question has accepted answers - jump to:

Answers

  • colincolin Posts: 15,240Questions: 1Answers: 2,599
    Answer ✓

    I'm not sure tbh, this is one for @sandy . I've raised it, so it doesn't get forgotten (DD-1379 for my reference) - and he'll reply back when next in.

    Ta,

    Colin

  • sandysandy Posts: 913Questions: 0Answers: 236
    Answer ✓

    Hi Kevin,

    Yes please for the test case, I think it may help me to see exactly what is happening :)

    I will try and take a look tomorrow for you.

    Thanks,
    Sandy

  • kthorngrenkthorngren Posts: 21,322Questions: 26Answers: 4,948

    Here is the test case:
    http://live.datatables.net/wenaxuti/6/edit

    I added a console.log statement to the search plug. Test steps:

    1. Search for london in the search input
    2. 13 rows are displayed
    3. Check the Technical Author checkbox
    4. The console will display search plugin 13 times
    5. Clear the search input and checkbox
    6. Select London in the SearchPane
    7. 13 rows are displayed
    8. Check the Technical Author checkbox
    9. The console will display search plugin 57 times

    As a side note I'm changing the way I'm handling removing duplicates. Not due to this behavior but its just a better solution. Just letting you know that I'm not relying on anything from this thread for my project.

    Kevin

  • sandysandy Posts: 913Questions: 0Answers: 236
    Answer ✓

    Hi Kevin,

    If you take a look at this block of code then you will see the following...

    • _fnFilter() is the Datatables searching filter, this is run before any custom filters that have been added.
    • fnFilterCustom() is where any custom filters added are being run.

    SearchPanes pushes onto the custom filter array as well as your custom filter. So for your above test steps when you are searching for london first of all there are only 13 rows to check when it comes to selecting Technical Author. However when you select London in the SearchPanes then this initial filter has not run yet, so all of the rows will be check by the custom filter.

    Hope this clears things up,
    Sandy

  • kthorngrenkthorngren Posts: 21,322Questions: 26Answers: 4,948

    Thanks. Figured there was a good reason for it.

    Kevin

This discussion has been closed.