HTML filtering broken?

HTML filtering broken?

vexvex Posts: 30Questions: 0Answers: 0
edited October 2012 in Bug reports
Hi,

I'm either missing something or the HTML-filtering seems to be broken. If I have a table with some cells containing HTML-data DataTables is supposed[1] to perform sorting/filtering on the textual value rather than the HTML code. However it doesn't seem to filter the HTML-code away even though I explicitly set the "sType" to "html". I tried it on your example[2] site and it seems broken there as well.

To quite a line from [1]:
[quote]As such the end user's filtering input will not match on the HTML tags (it is worth noting that the built in type of 'html' will perform this action,[/quote]

If you write "spry" into the search field (still using example at [2]) all three rows will still be visible. And the only reason for that must be that it matches the URL in the HTML which contains "sprymedia".


[1] http://datatables.net/development/filtering#type_based
[2] http://datatables.net/examples/advanced_init/html_sort.html


- EDIT -
I've resolved it by just using setting mRender on the offending columns to a custom function that does the HTML-filtering for me. Not sure if this is the new prefered way or not, but at least it works.
[code]function (data, type, full) {
return (type == 'filter' ? data.replace(/<[^>]+>/g, '') : data);
}[/code]


Regards,
Fredrik

Replies

  • joskjosk Posts: 13Questions: 0Answers: 0
    Its broken at the moment. Version 1.9.2 works like it should be. See the following thread:
    http://datatables.net/forums/discussion/179/searchfilter-finds-matches-in-html-tags/p1
  • allanallan Posts: 63,687Questions: 1Answers: 10,500 Site admin
    Yup - broken at the moment :-(. https://github.com/DataTables/DataTables/issues/128

    I hope to get a fix committed later on today.

    Allan
This discussion has been closed.