Using natural sorting and filtering that ignores html
Using natural sorting and filtering that ignores html

Link to test case:
Debugger code (debug.datatables.net):
Error messages shown:
Description of problem: I'm trying to use both of these plug-ins, but they don't seem to play nice together:
//cdn.datatables.net/plug-ins/1.11.5/filtering/type-based/html.js
//cdn.datatables.net/plug-ins/1.10.20/sorting/natural.js
I have 3 columns in my table that use html. I don't want the html used in the filter or in the sort, so I tried using both those together, but only the natural sorting seemed to work. Am I doing something wrong, or does anyone know how to get these to work together, or should I not even try?
Thanks.
"columnDefs": [
{
type: 'natural-nohtml', targets: [0, 1, 6]
},
{
type: 'html', targets: [0, 1, 6]
}
]
This question has accepted answers - jump to:
Answers
Maybe you can use Orthogonal data to remove the HTML for the sort and filter operations. Look for a regex pattern that can be used to remove the HTML elements leaving the data you want to sort and search.
Kevin
Yep, as Kevin said, something like this from this thread should do the trick,
Colin
What Kevin suggested probably will work, but I'm not sure how to do that. I guess I'll be learning something new today. The example Colin gave strips out the html from the display, which isn't what I want. Thanks
Adjust Colin's example like this:
http://live.datatables.net/lafagosi/66/edit
Basically if the orthogonal type is
display
return the original data. Otherwise strip the HTML for thefilter
,sort
andtype
operations.Kevin
Awesome, Kevin. Works like a charm! Thanks!