How to only allow single column sorting

How to only allow single column sorting

bruce808bruce808 Posts: 5Questions: 0Answers: 0
edited September 2010 in General
Hi Allan,

I'm just getting started with DataTables and it seems like you've done a beautiful job. I really like that the system allows multi-column sorting however my current situation only allows a sorting on a single column. I've been looking at ways of hacking around to disable the shift-click multi-column sorting but is there a simple way of doing this?

Bruce

Replies

  • bruce808bruce808 Posts: 5Questions: 0Answers: 0
    Hi Allan,

    Thanks to a comment from Jens Gutzeit I've figured this one out. I just needed to install an click event handler before DataTables handler and then disable the shiftKey.

    [code]
    $('#example thead th').click(function(event) {
    if (!$(event.target).hasClass('sorthandle')) {
    event.shiftKey = false;
    }
    });

    $('#example').dataTable();
    [/code]

    Best
    Bruce
  • allanallan Posts: 63,498Questions: 1Answers: 10,471 Site admin
    Hi Bruce,

    Thanks for the post back on this. That looks like a good solution to me. It's not something I had considered actually - not allowing multiple column sorting - but this looks like a good way of enforcing that. Thanks!

    Regards,
    Allan
  • bruce808bruce808 Posts: 5Questions: 0Answers: 0
    Hi Allan,

    Thanks for the fast confirmation. If I was implementing a new system I would definitely run with the multi-column sorting since it's cool and more powerful however I'm retrofitting an existing app that doesn't have it (based on another data grid). Rather than hacking up the backend and the UI in multiple places to implement the multi-column sorting I thought it would be more expedient to disable it. ;)

    Best
    Bruce
This discussion has been closed.