filtering only works after sorting

filtering only works after sorting

ifaceiface Posts: 23Questions: 8Answers: 0
edited September 2010 in General
Hello
I'm hoping someone will be able to provide some guidance.

I'm using column based sorting with the fnFilter() function. I've also added the examples from the DOM based sorting.
http://www.datatables.net/examples/plug-ins/dom_sort.html

The column contains html input elements and I've set up "sSortDataType": "dom-text" in the aoColumnDefs.

Sorting on all columns works great. But I'm only able to filter on a column containing input text elements after I sort it. Filtering on the column prior to sort finds no matches.


Note: columns that contain plain text filter as expected.

Replies

  • allanallan Posts: 64,610Questions: 1Answers: 10,683 Site admin
    The reason for this is that the functions to read the information live from the DOM are only called when a sort occurs - thereafter that information is then available to the filter to be searched through (the block at line 4200 in DataTables 1.7.2 controls this). The initial sort that DataTables does should allow this to work on the first draw, and it appears to do so from the example, but if you then change the information, the filter might be slightly out of date and need to be changed. This could be done in one of a couple of ways:

    1. An API plug-in function which will effectively do the same thing as the sort (line 4200) to repopulate from the DOM, and then you can call that whenever is needed.

    2. Sort the table again, using fnSort and the current sort settings (fnSettings().aaSorting).

    Allan
This discussion has been closed.