filtering rows based on one column

filtering rows based on one column

offbeatmammaloffbeatmammal Posts: 3Questions: 1Answers: 0

I have a table with (for sake of argument) one of the columns being "author"
I want to filter visibility of rows in that column to only show a selected author

at the moment, I'm trying to do it via a

table.rows().every( function () {
    ... logic to determine show/hide
    this.show()
}

but getting an error because that's obviously not the right way to use the function!

Can someone point me to either a good way to show/hide the selected row in that loop or a better way to filter visibility for matching text in a specific column.

Using simple jQuery to parse the underlying table and show/hide rows sort of works how I want, but the pagination doesn't reflect the change and still shows the original pages with the results still in their unfiltered positions

This question has accepted answers - jump to:

Answers

  • kthorngrenkthorngren Posts: 21,182Questions: 26Answers: 4,925
    Answer ✓

    The column().search() API is the way to filter rows based on the text of a particular column.

    Kevin

  • offbeatmammaloffbeatmammal Posts: 3Questions: 1Answers: 0

    worked like a charm, thanks.

    as a cheeky followup ... is there a way to search on cell properties such as assigned classes in addition to the text?

    I've got some rows where a cell has a specific class assigned to highlight it as an urgent order, and would like to filter to just show those in the same way

  • offbeatmammaloffbeatmammal Posts: 3Questions: 1Answers: 0

    so, a bit more digging and while the column().search() doesn't seem to let me at the node properties, building a custom search and using

    $(table.row(dataIndex).node()).find("td:nth-child(1)").hasClass("urgent")
    

    does allow me to filter these on and off

  • kthorngrenkthorngren Posts: 21,182Questions: 26Answers: 4,925
    Answer ✓

    You will need to create a search plugin. See if this thread gets you started.

    Kevin

Sign In or Register to comment.