DataTables sort by non-orderable column
DataTables sort by non-orderable column

Hi, everyone!
I've faced with a problem (or probably feature). When I make the first column of a table non-orderable via data-orderable="false"
attribute, and don't setup default order, DataTable sorts data by this field anyway. Here is an example. IMO, more appropriate behavior will be sorting by first "orderable" column instead of first one.
This discussion has been closed.
Replies
Looks like
data-order='[]'
attribute could solve this problem. Although, the default behaviour looks weird to me.For ajax sourced data this is not the default behavior. If you don't specify "order" like in here:
you get the data in the exact sequence the server returns the data to the client.
Yep, by default the sorting occurs on the first column, whether ordering is permitted or not. If you want to change that order, you can use
order
,Colin
...mhhh... that surprises me a little.
Since Editor doesn't support it I built my own "SELECT DISTINCT" and "ORDER BY" using PHP like this:
Without specifying "order" on the client side this provides me with exactly the ordering expected which is not on the first column of the Data Table.
I do this because I need the "orginal order" (the one from the server) for my Excel export:
to get my Excel export right while for the Data Table I want to implement a different order which is this one:
@rf1234, I have the same problem with ajax-data as well. Sorry, couldn't provide you with an example. But based on the source code I see no different between ajax and non-ajax data in this particular case.
@colin, thank you for your answer. Suppose, this is the way I should follow. So, it isn't a bug, but feature.