Waseem
Waseem

Reputation: 1408

How to get extjs grid cell component

I want to get grid's cell and fire cellclick event on it programmatically. How can I implement it?So far I am successful to get cell's dom element like this

var cell = pos.view.getCellByPosition(newPos);

but when I execute the following code

cell.fireEvent('click');

it gives me error because its not Ext Component. Is there any way to get Ext Component from Dom Element. Dom element has an ID but when I use Ext.getCmp(cell.id); it returns nothing.

Upvotes: 2

Views: 4404

Answers (2)

dherbolt
dherbolt

Reputation: 256

Grid cell has no representation by an ExtJS component therefore you cannot fire event on it. It is possible fire manually DOM event for cell DOM element (http://jehiah.cz/a/firing-javascript-events-properly) or fire event itemclick for Ext.grid.View component.

Upvotes: 4

Gregor
Gregor

Reputation: 4434

The cellclick event is actually fired from the underlying View, not the cell itself.

So try to fire the following event:

pos.view.fireEvent("cellclick")

You should fill the missing params, as cellclick should deliver the following:

cellclick( Ext.view.Table this, HTMLElement td, Number cellIndex,
           Ext.data.Model record, HTMLElement tr, Number rowIndex,
           Ext.EventObject e, Object eOpts )

Upvotes: 0

Related Questions