Single column sort only, with correct directional arrows

Single column sort only, with correct directional arrows

bidonbidon Posts: 28Questions: 0Answers: 0
edited February 2012 in General
I want column sorting, with my server side data, but I don't want the header UI to give the impression that multiple columns can sort.

IOW, turn off the shift-click multiple column sort selection.

How is this done?

Replies

  • allanallan Posts: 63,542Questions: 1Answers: 10,476 Site admin
    Actually you can't at the moment - there isn't an option to disable the built in multi-column sorting option. What you could do is unbind the sort listeners DataTables adds and then bind you own with fnSort - that would work well, although obviously you would need to have a little extra code to do it.

    Why can't you have multi-column sorting with server-side processing?

    Allan
  • bidonbidon Posts: 28Questions: 0Answers: 0
    Mostly a lack of time to allow infinite tables to sort on infinite columns on the pages, for the release I'm on. I'm talking back end query support.
  • bidonbidon Posts: 28Questions: 0Answers: 0
    But thanks for the info, project as a whole.
  • allanallan Posts: 63,542Questions: 1Answers: 10,476 Site admin
    There are a number of server-side scripts here which might be of some interest: http://datatables.net/development/server-side/ . The majority of them offer multi-column sorting, so you might be able to take some ideas from them.

    Regards,
    Allan
  • bidonbidon Posts: 28Questions: 0Answers: 0
    This would have been very handy earlier, we have a RoR back end. Some pages are not dissimilar to your example.

    However, others cross multiple models/tables, and have nasty, dynamic SQL statements. It is all doable of course, but time simply won't allow.
  • allanallan Posts: 63,542Questions: 1Answers: 10,476 Site admin
    Yup it can get complicated!

    Should you want a quick fix, you could just comment out the shift sort in DataTables core: https://github.com/DataTables/DataTables/blob/master/media/js/jquery.dataTables.js#L3981 . A more complete solution would be to attach your own fnSort listener. I'll look at making this optional in future!

    Allan
This discussion has been closed.