Filtering DOM Elements

Filtering DOM Elements

AlexWAlexW Posts: 2Questions: 0Answers: 0
edited July 2012 in General
Hi,

i would like to filter/search for the contents of some DOM elements. I also implemented some custom sorting types (german date/ number format), but i think this doesn't matter here.

This DataTables-example exactly shows my problem:
http://datatables.net/release-datatables/examples/plug-ins/dom_sort.html

Try to Search for: "OSX" - > doesn't work.
Now sort the table based on the "Platform(s)" column.
Search for "OSX" again - > now it works!

Is there a way to make the search work before sorting the column?

Thank you!
Alex

Replies

  • allanallan Posts: 63,535Questions: 1Answers: 10,475 Site admin
    So the problem is that the filtering only occurs on the cached data (to speed the process up), but that cache refresh only occurs when the table is sorted. Perhaps it should also occur before every filter.

    This seems to apply here:

    [quote]
    There are only two hard things in Computer Science: cache invalidation and naming things.
    -- Phil Karlton
    [/quote]

    :-)

    So that's option 1.

    Option 2 - call sort on the table to refresh the sort when you start filtering (bit ugly, but it would work as is)

    Option 3 - use a custom filter that will search DOM elements - http://datatables.net/development/filtering .

    I think option 1 is the most attractive. I'm not 100% sure I'll have time to get it into 1.9.3, but I'll certainly try!

    Allan
This discussion has been closed.