PDA

View Full Version : See node properties in a tree panel from a grid



chechuironman
14 Jul 2010, 4:59 AM
Hi guys,

I have a tree panel with several nodes which I identify by the property node.id, thsi is in the west panel, in the east panel i have agrid with several buttons.
What I want to do is, when i click a button and a node and a row in teh grid is selected then an action is done.

I dont know how to handel this...I gues with handlers maybe...I dont know...someone to help me??...some example??

thanks

Condor
14 Jul 2010, 5:14 AM
Your button handler obviously needs a reference to the grid and to the tree.

The easiest method is to give both the grid and the tree and id and use:

var grid = Ext.getCmp('id-of-grid');
var tree = Ext.getCmp('id-of-tree');

chechuironman
15 Jul 2010, 3:56 AM
I tried what you say...but it doesnt work...all the coponent i create i do like this:

this.component= new component

Maybe this is the problem??? cause I want to get the component that I create from a component which is created by this...I mean the son want to get the father..

Condor
15 Jul 2010, 4:36 AM
I meant:

var grid = new Ext.grid.GridPanel({
id: 'id-of-grid',
...
});
var tree = new Ext.grid.TreePanel({
id: 'id-of-tree',
...
});
var button = new Ext.Button({
...
handler: function(){
var grid = Ext.getCmp('id-of-grid');
var tree = Ext.getCmp('id-of-tree');
}
});

chechuironman
16 Jul 2010, 4:26 AM
thank you it works...but...how can i get the node id...I mean I have the element tree, and this elemente have several nodes...and one is selected...how can I get the node id which is selected

thanks

Condor
16 Jul 2010, 5:04 AM
var node = tree.getSelectionModel().getSelectedNode();
var record = grid.getSelectionModel().getSelected();