PDA

View Full Version : ComponentQuery.query / MVC selector Question - Grid Header Menu



numenory
11 Jun 2013, 3:05 AM
Again excuse my poor explanation, but i want to attach a click listener to the 'Sort Ascending' / 'Sort Descending' menu item found on the standard menu on a grid column header.

I have an MVC app and i can attach a listener thus in the controller:

this.control({

'menu' : {
click: this.doAFunction
}

})

This will however obviously trigger for any menu on the page, I have been trying to attach it to the grid panel, really to its header, but i cannot find the solution.....

My view is defined...

Ext.define('App.view.orders.Grid' ,{ extend: 'Ext.grid.Panel',
alias : 'widget.orderList'
.......

And in the controller I can get things to work like:

'orderList' : { headerclick: this.headerClickFunc,
},

'orderList button' : {
click: this.buttonFunc
}





Lee

Songle
11 Jun 2013, 10:51 PM
You could add a listener to the grid that fires whenever sort is used and query the sortInfo to find out what you want.



var grid = new Ext.grid.GridPanel({
listeners: {
sortchange: function(grid, sortinfo) {
console.log(grid, sortinfo)
}
}
});

slemmon
12 Jun 2013, 8:25 PM
The headerclick event might also be what you want (in case you're also sorting programmatically)
http://docs.sencha.com/extjs/4.2.0/#!/api/Ext.grid.header.Container-event-headerclick


'mygrid headercontainer' : {
headerclick: function () {}
}

numenory
16 Jun 2013, 8:16 AM
sortchange worked perfectly for what i needed, was already using headerclick, but that is not needed now as sortchange picks up both