0

I'm implementing a multi-sort for a grid. I want to use the sortchange event for this, but I have to cancel the event so I can call the store with my own sorting config.

This didn't work:

oGrid.on('sortchange', function(oColumnContainer, oColumn, strSortOrder){
  //...
  return false;
})
K..
  • 4,044
  • 6
  • 40
  • 85
  • This is going to be quite complicated. Are you willing to extend the column class for a solution? If so I can show you how. – Reimius Feb 19 '13 at 15:46

1 Answers1

0

Found a solution by myself.

When I need my multi-sort, I set all columns on the grid to sortable: false at creation time (seems like it is not possible to do this on-the-fly)

Then I set a on('headerclick, function() {...})` to all the column-objects right after I created the grid.

The sortable: false prevents the click event on the header from sorting the table, but later I can still call sort() on the store programatically with the saved columns.

var oGrid = Ext.create( 'Ext.grid.Panel', {
  ...
  columns: [
    { ..., sortable: false }
  ]
});

for( i in oGrid.columns ) {
  oGrid.columns[i].on('headerclick', function(){...});
}
K..
  • 4,044
  • 6
  • 40
  • 85