SlickGrid icon indicating copy to clipboard operation
SlickGrid copied to clipboard

Slickgrid 3 click sorting

Open vipk1234 opened this issue 9 years ago • 4 comments

I'm trying to implement 3 click sorting for slickgrid and i am trying to achieve this by subscribing to onHeaderClick event and keeping track of the number of click so i can implement ascending, descending and reset state. the issue i'm having is when i set sortable flag to true, the default onHeaderClick in slick.grid file gets executed too. Also, i have subscribed to custom onSort event as well and I'm not sure how to all the custom onSort event from the custom onHeaderClick event.

Any suggestions on this would help.

Thank you

vipk1234 avatar Nov 09 '16 22:11 vipk1234

suggest using my repo, it's a more up to date version of this one. the best way to mod this would be in the grid code itself slick.grid.js:

function setupColumnSort() {
    ...
      var sortOpts = null;
      var i = 0;
      for (; i < sortColumns.length; i++) {
        if (sortColumns[i].columnId == column.id) {
          sortOpts = sortColumns[i];
          sortOpts.sortAsc = !sortOpts.sortAsc;
          break;
        }
      }

this is where the grid click is handled. changing the logic would be simple. in fact, i'm a big fan of three state clicks so i might add a grid option for that to my repo.

6pac avatar Nov 10 '16 00:11 6pac

generally with an event, returning the value false stops the default event occurring, as well as events for parent elements.

6pac avatar Nov 10 '16 00:11 6pac

also, assuming that you are using example-multi-column-sort.html as a starting point

6pac avatar Nov 10 '16 01:11 6pac

First of all thanks for getting back, I did considered modifying the grid code but this is common library shared by multiple projects where all the other projects want regular sorting accept this one. that's the reason i was trying to edit it by subscribing to the event.

vipk1234 avatar Nov 10 '16 15:11 vipk1234