Is it possible to filter a table based on the cell classes?

Is it possible to filter a table based on the cell classes?

sviviansvivian Posts: 13Questions: 0Answers: 0
edited August 2010 in General
I have a table that shows various ticks and crosses in it. A ticked cell has this HTML:

[code][/code]

And unticked:

[code][/code]

I would like to add a filter control as a checkbox, so that when the checkbox is checked, it filters all ticked cells in that column. Is this possible?

I've started with this:

[code]$('#chk-var1').click( function() {
oTable.fnFilter( this.value, 3 );
} );[/code]

But I don't know where to go from here. Any guidance would be much appreciated!

Replies

  • sviviansvivian Posts: 13Questions: 0Answers: 0
    Well I found a solution that works. I put a 'Y' in the columns that had a tick, with the CSS property "text-indent:-9999em" to hide it. Now I can filter on the text.

    If there are any better solutions, I'd love to hear :)
  • allanallan Posts: 63,498Questions: 1Answers: 10,471 Site admin
    You can use custom row filtering ( http://datatables.net/development/filtering#row_filters ) which will give you access to the DOM for the row, and you just return true or false if you want it to be filtered in or out.

    Regards,
    Allan
This discussion has been closed.