Filter rows by CSS selector

Filter rows by CSS selector

taylor_hunttaylor_hunt Posts: 3Questions: 1Answers: 0
edited November 2016 in Free community support

Example fiddle: http://live.datatables.net/gamuxure/1/edit

I'm using documentTable.rows('selector-string') to grab rows matching a CSS selector, then attempting to filter the table by chaining .draw() on that.

That appears to not be the right thing, as the table doesn't appear to change. No errors in the console, unfortunately. I'm tasked with fixing up one page on an existing site, so I'm afraid I don't fully understand the DataTables API even after browsing the docs.

This question has an accepted answers - jump to answer

Answers

  • taylor_hunttaylor_hunt Posts: 3Questions: 1Answers: 0
    edited November 2016

    [deleted]

  • allanallan Posts: 63,823Questions: 1Answers: 10,517 Site admin
    Answer ✓

    DataTables filtering is string based - there isn't a trivial way to have it display rows based on a CSS selector (you can easily select rows as you have done, but not reduce the display down to that).

    Are you able to change the table so that data-category and data-type are actually columns in the table (which you can hide using columns.visible)? If so, that is the way I would suggest you do it then you can easily use column().search().

    If that isn't an option you would need to use a custom search plug-in.

    Allan

  • taylor_hunttaylor_hunt Posts: 3Questions: 1Answers: 0

    Sure, I can try that. Thank you.

This discussion has been closed.