Using natural sorting and filtering that ignores html

Using natural sorting and filtering that ignores html

kkittell518kkittell518 Posts: 25Questions: 8Answers: 0

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

  • kthorngrenkthorngren Posts: 21,143Questions: 26Answers: 4,918
    Answer ✓

    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

  • colincolin Posts: 15,237Questions: 1Answers: 2,598

    Yep, as Kevin said, something like this from this thread should do the trick,

    Colin

  • kkittell518kkittell518 Posts: 25Questions: 8Answers: 0

    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

  • kthorngrenkthorngren Posts: 21,143Questions: 26Answers: 4,918
    Answer ✓

    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 the filter, sort and type operations.

    Kevin

  • kkittell518kkittell518 Posts: 25Questions: 8Answers: 0

    Awesome, Kevin. Works like a charm! Thanks!

Sign In or Register to comment.