View Full Version : Get column id from Grid Header Menu ?

7 May 2011, 3:23 AM
I now know how to add own menu item in a header of grid but and...

When i click on menu item in a header menu I need to grab column id which header menu i clicked. How can i do this?

20 Jul 2011, 12:25 PM
I'm in the same position. New to extjs and have gotten my own item in the gridview hmenu. Now just need to get the column index or id on click of that item. Any ideas?

20 Jul 2011, 2:00 PM
I`m actually does not entirely sure what you mean under 'id'. If you need to obtain dataIndex, let`s investigate part of source GridView:

handleHdMenuClick : function(item) {
var store = this.ds,
dataIndex = this.cm.getDataIndex(this.hdCtxIndex);

switch (item.getItemId()) {
case 'asc':

20 Jul 2011, 5:13 PM
Thanks for the help. Still a bit confused though. What I'm looking to do is somehow have the menu item handler get access to the column index (not the dataIndex) for which that hmenu was fired from. I've put down what i'm working with so far and just can't figure out how to access that column index value in the menu item handler. Check out this code below and see specifically the handler function for the hmenu. I've been searching for hours on this and and stumped....any direction would be much appreciated :)

var myGridPanel = Ext.extend(Ext.grid.GridPanel, {

constructor: function(config){

myGridPanel.superclass.constructor.call(this, config);


expcol: function() {

this.on('viewready', function() {

text: "Expand",
icon: 'icons/add.png',
scope: this,
handler: function(item, e) {


// Some logic using column index....





27 Feb 2012, 2:51 AM
in your handler function try something like this:

var thisCol = this.view.cm.getColumnAt(this.view.hdCtxIndex);