cyberhobo / ColumnFilterWidgets

This is an add-on for the DataTables plugin for jQuery that creates filtering widgets based on the data in table columns.
69 stars 34 forks source link

Filter fails when table cells have interior wrapper #3

Open studioleland opened 12 years ago

studioleland commented 12 years ago

< 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.

cyberhobo commented 12 years ago

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.

Surt commented 12 years ago

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

cyberhobo commented 12 years ago

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.

studioleland commented 12 years ago

Found this to be the case with sSeparator option.

juanpickselov commented 12 years ago

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.

Muhahe commented 12 years ago

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)

FriendlyWP commented 11 years ago

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 commented 11 years ago

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

cyberhobo commented 11 years ago

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.

FriendlyWP commented 11 years ago

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