PDA

View Full Version : grid.up();



kishorkoli8
26 Jan 2015, 10:10 PM
Hello experts,
I am trying to get a grid with up( ) method, it works fine with same grid as this.up('id').
But when I am trying the same from another grid it returns undefined. What I the correct way to achieve it.

aaugen
27 Jan 2015, 12:26 AM
Hi kishorkoli8,

Can you put code with specific tag [CODE] to explain more your problem...

kishorkoli8
27 Jan 2015, 12:32 AM
Thanks aaugen for your reply.


handler: function (grid, rowIndex, colIndex) {
var myGrid = this.up('stockgrid');
}

'stockgrid' is a different view name, and this handler is of different grid.

and both of these grids are on different tab panels.

aaugen
27 Jan 2015, 12:50 AM
Be carreful of "this" use in your handler fonction.
In most cases, the value of keyword this is determined by how a function is called. It can't be set by assignment during execution, and it may be different each time the function is called.
If you want to get component located above your grid in DOM Hierarchie, use instead the grid parameter in your handler fonction:



handler: function (grid, rowIndex, colIndex) {
var myGrid = grid.up('stockgrid');
}


If you want to get component from different tap, you need to get first your tabpanel by up() method and after that your tab by down() method:



handler: function (grid, rowIndex, colIndex) {
var myGrid = grid.up('tabpanel').down('stockgrid');
}

kishorkoli8
27 Jan 2015, 1:16 AM
I have tried the way you suggested like,

var myGrid = grid.up('accrid').down('stockgrid');

but it gives,
TypeError: grid.up(...) is undefined (in firebug).

my tabpanel code is as follows


Ext.define('App.view.impact.ImpactTabPanelView',{
extend : 'Ext.tab.Panel',
alias : 'widget.twtabpanelview',
deferredRender: false,
//layout : 'fit',
autoScroll:true,
// padding: '0 150 0 150',
renderTo : Ext.getBody(),
//title : "Document Selection",
id:'adminTabPanel',
plain : false,
height : 500,
tabPosition : "top",
items : [{
title : 'Document Selection',
xtype: 'acc',
id: 'accrid'
},{
title : 'TW Grid Preview',
xtype:'twgridpreview'


}
]
});

kishorkoli8
27 Jan 2015, 1:39 AM
thanks aaugen
It worked for me..thank you so much.=D>