Sorting filtered data

Sorting filtered data

adamcciadamcci Posts: 2Questions: 2Answers: 0

Is it possible to sort the newly filtered data? For example, if I have 100 records and on the search box I begin typing a key word and my results are now filtered down to 25 records; is it possible to apply a sort on the 25 records based on a condition?

In my use-case I have a hidden column with a numeric value I need to sort the results based on.

Answers

  • glendersonglenderson Posts: 231Questions: 11Answers: 29

    If you use the orderData feature, you can sort any column based upon another column.

    https://datatables.net/reference/option/columns.orderData.

    From a user perspective, I hope that you don't mean you want to change the sorting condition because a filter was applied. The sorting method should be persistent before and after the sort (that is, the sort order should not change because I entered a filter value).

  • allanallan Posts: 61,971Questions: 1Answers: 10,160 Site admin

    is it possible to apply a sort on the 25 records based on a condition?

    Ordering in DataTables will always be performed on all rows in the table - not just the filtered sub-set. However, isn't the end result the same for the end user? Regardless of filtering the ordering will be the same (I presume, and as glenderson indicates).

    Allan

This discussion has been closed.