PDA

View Full Version : How do I get column name from rowselection in an ExtJS grid?



CliffM
19 Aug 2009, 12:05 PM
I have a extjs gridpanel setup, and I want to be able to do things based on a user clicking on text or icons in the grid. For example, filter the grid if the user clicks (or double clicks) a word in a column, or show a popup if the user clicks on an icon. I can easily get the row they clicked on, and values by column name from that row, but I don't know which column was clicked.


Alternatively, I could add an onClick to the entire grid, which I could then get the individual text from the row/column, but I don't know what row index or column that value belongs to. I could add a CSS class that would tell me a column name, but that seems like a hack.


Is there anything built-in that can do this?

avsomeren
19 Aug 2009, 12:23 PM
Might be worth looking at :

http://extjs.com/deploy/dev/docs/?class=Ext.grid.CellSelectionModel

avsomeren
20 Aug 2009, 11:41 AM
I discovered the following on Saki's site :
http://extjs.com/forum/showthread.php?t=30411

Might cover what you are looking for...

dlbjr
20 Aug 2009, 11:51 AM
g.on('cellclick', function(grid, rowIndex, columnIndex, e) {
//Do what ever
});

g.on('cellcontextmenu', function(grid, rowIndex, columnIndex, e) {
//Do what ever
});