HTML sort type bug?
HTML sort type bug?
jsmreese
Posts: 6Questions: 0Answers: 0
One column of my table has mouseover javascript:
[code]
~Name~
[/code]
This column is initialized with sType as html, and is filtered by an input text box that filters on that column only:
[code]
$("thead td.nSearch input").keyup( function () {
oTable.fnFilter( this.value, $("thead td.nSearch input").index(this) );
} );
[/code]
What *should* be matched on filter is only the ~Name~ which gets replaced with actual names when the table is generated.
What *is* matched is everything after and including this: , WIDTH
Up until and including the final result of ~Name~
The trailing doesn't seem to be matched, and I don't believe the preceding ' is matched.
[code]
~Name~
[/code]
This column is initialized with sType as html, and is filtered by an input text box that filters on that column only:
[code]
$("thead td.nSearch input").keyup( function () {
oTable.fnFilter( this.value, $("thead td.nSearch input").index(this) );
} );
[/code]
What *should* be matched on filter is only the ~Name~ which gets replaced with actual names when the table is generated.
What *is* matched is everything after and including this: , WIDTH
Up until and including the final result of ~Name~
The trailing doesn't seem to be matched, and I don't believe the preceding ' is matched.
This discussion has been closed.
Replies
And BTW, I see this in both IE 8.0 and Firefox 3.5.9.
I'll have a look at how difficult it will be to correct this...
Allan
[code]
.replace(/\n/g," ").replace( /<[^\r\n<>]*?>/g, "" ).replace( /<[^\r\n<>]*?>/g, "" );
[/code]
This only removes nested HTML tags that are nested two deep (as mine are with the HTML within the mouseover function) so it's not a completely general solution but it is a little smarter than the previous version and isn't much slower.
John
I've just been investigating how this can be improved in DataTables, and found a suitable solution. It does have a slight performance impact though, so what I've done is to wrap it up into a plug-in filtering function: http://datatables.net/plug-ins/filtering#html_column .
This will replace the built-in 'html' filtering method for an 'html' type column with a method for complete removal of tags. I've not included it in DataTables by default due to the performance impact, and this is a fairly rare use case - but it is there if you (or anyone else!) would like to use it now :-) Note that it might be suitable to do this for a sort function as well...
Regards,
Allan