Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ExtJS 4 - Grid cell events?

In ExtJS 3.x the Grid Panel component had bindable events for cells including cellclick, cellcontextmenu, celldblclick, and cellmousedown, and listeners on these events were passed both the rowIndex and colIndex of the cell that fired the event.

In 4.x these events are gone, there are only item* events (i.e. itemclick) but these events fire for the grids' rows as a whole and therefore are only passed the row's index.

Is there any way to determine which column was clicked using these events, or is there an alternate way of attaching listeners to the cells?

like image 998
Bill Dami Avatar asked Dec 08 '11 19:12

Bill Dami


2 Answers

I think the key to your question lies in the Selection Model chosen for the grid. The default is row selector so the item select events operate on rows. Check out cell selector API here: http://docs.sencha.com/ext-js/4-0/#!/api/Ext.selection.CellModel-event-select

like image 93
dbrin Avatar answered Nov 07 '22 16:11

dbrin


(ExtJS 4.1)

You could also hook on the (undocumented) uievent of the grid's view:

grid.getView().on( 'uievent', this.onUIEvent, this);

onUIEvent: function ( aType, aView, aCell, aRecordIndex, aCellIndex, aEvent )
{
    console.log( aRecordIndex + ' : ' + aCellIndex );
},
like image 25
Izhaki Avatar answered Nov 07 '22 16:11

Izhaki