PDA

View Full Version : addListener



J. Bamb
16 Mar 2017, 5:38 AM
Hello!
I use ExtJS 2.0. I have a basic component used in several modules:

my.component.ResultGrid=function{

varResultGrid=newExt.grid.GridPanel({
listeners:{
'rowdblclick':function(grid, rowIndex, event){
loadRecord(rowIndex);
}
}
});

my.component.ResultGrid.superclass.constructor.call(this,{
items:[ResultGrid]
});

function loadRecord(rowIndex){
alert(rowIndex);
}

function readRecord(rowIndex){
alert(rowIndex);
}

};
Ext.extend(my.component.ResultGrid,Ext.Panel);
I want to include it in one of modules:

my.MyPanel.Register=function(){

varResultGrid=new my.component.ResultGrid();

ResultGrid.items.items[0].addListener({
rowclick:function(grid, rowIndex, event){
this.searchResultGrid.readRecord(rowIndex);
}
});

my.MyPanel.Register.superclass.constructor.call(this,{
items:[ResultGrid]
});

};
Ext.extend(my.MyPanel.Register,Ext.Panel);
Also I appropriate it the additional listener, but I receive an error:

Uncaught TypeError: Cannot read property 'readRecord' of undefined
As it is correct to cause function readRecord in the added listener rowclick?
Many thanks in advance!