ColumnFilterWidgets icon indicating copy to clipboard operation
ColumnFilterWidgets copied to clipboard

Filter fails when table cells have interior wrapper

Open studioleland opened this issue 13 years ago • 10 comments

< td >value< /td > < /code > works just fine for filtering value.

For some reason < td >< span >value< /span >< /td > shows up in the filters list but when selected it shows an empty result set.

I couldn't quite figure out how to do the code markdown in github.

studioleland avatar Nov 01 '11 05:11 studioleland

I just noticed this as well. ColumnFilterWidgets doesn't handle HTML markup in cells. I'm thinking an option to do a sloppier match that would just look for a term anywhere in the cell content might be good enough for most scenarios.

cyberhobo avatar Nov 01 '11 14:11 cyberhobo

Same problem here. Using cells with hiperlinks. The filters fills ok, but when I select one to to filter it fails.

Surt avatar Jan 23 '12 18:01 Surt

A little more testing indicates that the failure only happens when the sSeparator option is used. Let me know if you have a test case where that's not true.

cyberhobo avatar Jan 31 '12 00:01 cyberhobo

Found this to be the case with sSeparator option.

studioleland avatar Feb 02 '12 22:02 studioleland

the list gets created, but the values of each option element are filled with the markup surrounding your text even if you tell datatables sType is HTML. Regardless of using the sSeparator or not, a filter on a column with markup fails.

juanpickselov avatar Feb 14 '12 15:02 juanpickselov

Hi guys, i tried to use column filter widget to work with tables with html links, where i have same text but diferent ID in hyperlink. I manage to add sValue = sValue.replace(/(<.*?>)/ig,""); on 59 line (filling asResultData array loop) so in dropdown box are datas without html. This solves problem for me, hope it helps. (but i dont know how jquery works, so its advice from mere nOOb)

Muhahe avatar Jun 30 '12 16:06 Muhahe

Seeing the same problem.... my cells contain hyperlinks separated by commas. Filtering works fine, but the option tags contain the link HTML as well as the text. When using those filters, it returns blank results each time.

I tried Muhahe's fix above but it didn't work... Any ideas? Thanks so much!

FriendlyWP avatar Aug 13 '13 18:08 FriendlyWP

The fix for this is to change line 57 of ColumnFilterWidgets.js (v 1.0.3) to:

var sValue = $('<div>' + this.fnGetData(iRow, iColumn) + '</div>').text();

Thanks to Alexs6 for this: http://datatables.net/forums/discussion/comment/41317#Comment_41317

FriendlyWP avatar Aug 14 '13 15:08 FriendlyWP

Alexs6's solution causes a new problem where values that have an entity such as & in them no longer work. The HTML examples have one of these in the Platform(s) widget, "Win 95+ (Entity: &)", and there is a unit test case. I'd like to find a fix that handles both cases.

cyberhobo avatar Aug 20 '13 22:08 cyberhobo

I've had to move over to a different plugin to get this feature working, maybe there's code in that that could help here. I'm not a jQuery pro so I'm not sure what/how to go about it, but this is the other plugin: https://github.com/vedmack/yadcf

FriendlyWP avatar Aug 22 '13 16:08 FriendlyWP