How do you make a fireEvent
itemclick
after the store loads.
I have this but it doesn't work:
pcfstore.on('load', function(){
//auto select first row;
Ext.getCmp('pcf_grid').getSelectionModel().select(0); // this works
//fire itemclick event
var grid= Ext.getCmp('pcf_grid');
grid.fireEvent('itemclick', grid, 0); //this doesnt work
});
Here is my itemclick
event in grid view:
viewConfig: {
listeners: {
itemclick: function(dv, record, item, index, e) {
alert(record.data.code);
}
}
}
Basically when the grid loads, it should fire the alert window of the selected first row of the grid.
itemclick
is event of View
but not of Grid
. Try to use:
grid.getview().fireEvent('itemclick', grid, 0);
And by the way why not use selectionchange
instead.
UPDATE
If you have both itemcontextmenu
and selectionchange
handlers it can be a little bit confusing. In this case I recommend back to square one and use itemclick
event.
But your code need to have some modifications:
itemclick
event to grid, NOT to it's view.itemclick
pass actual record, NOT an indexlike this:
grid.getSelectionModel().select(0);
grid.fireEvent('itemclick', grid, grid.getSelectionModel().getLastSelected());
And here is fiddle to demonstrate what I'm talking about.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With