PDA

View Full Version : on CLick Header event



24 Apr 2012, 4:16 AM
Hi folks,

I have a grid with different columns and different headers.

I want to fire a on click event on header.

Presently I am using this code.

var cols = [
{id : 'name', header: "Account Name", width: 225, sortable: true, dataIndex: 'name'},
{header: "Industry", width: 225, sortable: true, dataIndex: 'column1'},
{header: "Type", width: 225, sortable: true, dataIndex: 'column2'},
{header: "Action", width: 225, menuDisabled: true,resizable: true, dataIndex: 'img', sortable: true, align: 'left'}
];
Let me know your suggestions over this ASAP.

scottmartin
24 Apr 2012, 8:50 PM
You can place a listener on the column:



Ext.create('Ext.grid.Panel', {
title: 'Simpsons',
store: Ext.data.StoreManager.lookup('simpsonsStore'),
columns: [
{ header: 'Name', dataIndex: 'name' },
{ header: 'Email', dataIndex: 'email', flex: 1 },
{ header: 'Phone', dataIndex: 'phone',
listeners: {
headerclick: function(){
alert('header clicked!');
}
}
}
],
height: 200,
width: 400,
renderTo: Ext.getBody()
});


Regards,
Scott.