HTML filtering broken?
HTML filtering broken?
vex
Posts: 30Questions: 0Answers: 0
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
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
This discussion has been closed.
Replies
http://datatables.net/forums/discussion/179/searchfilter-finds-matches-in-html-tags/p1
I hope to get a fix committed later on today.
Allan