Sorting only filtered rows

Sorting only filtered rows

ionutcionutc Posts: 2Questions: 0Answers: 0
edited June 2013 in DataTables 1.9
Is it possible to have sorting happen after filtering and done only for the filtered rows ?

I looked a bit in the DT code and noticed that _fnSort calls _fnFilterComplete after it's done sorting.

Replies

  • allanallan Posts: 63,383Questions: 1Answers: 10,449 Site admin
    No - it sorts the full data set and then applied the filter. That is just the way DataTables works! You could change it, sure, but there isn't a configuration option to do so.

    Allan
  • ionutcionutc Posts: 2Questions: 0Answers: 0
    Thank you for answering Allan !!!

    Would you be able to suggest the "proper" way to implement this "filter then sort" scenario ?

    I am thinking it would be useful for other people to avoid sorting in scenarios where the filtered set is very narrow compared with the whole set. In my particular case, I have to filter+sort a set of thousands of entries of which only a handful are displayed (10-20) every 3 seconds. I want to avoid as much as possible that spike in CPU usage on a IE8 ;-).

    Thank you for this wonderful component, it sure saved me a lot of time !

    Ionut
This discussion has been closed.