PDA

View Full Version : Select row in a grid



farnice
30 Sep 2011, 6:15 AM
Hi everybody,

I want to get info from my selected row in a grid,
I did it with
grid.getSelectionModel().getSelection();
before I rewrite everything with viewport.but now I don't know how to select my grid from the viewport panel. ( cuz now the code doesn't now the grid)
is this a way to select the specific grid (2nd one) and use getSelectionModel().getSelection(); or I should use another function to do that at all ?

thank you very much for helping :)

part of the code which is relevant, is like this.

var controlPanel = new Ext.Viewport({
title:'test',
items:[{
xtype:'tabpanel',
activeTab:0,
items:[{
xtype:'grid',
store: statusStore,
},
{
xtype:'grid',
id:'tasks',
store: tasksStore,
title:'Tasks',
}]
});

Uberdude
30 Sep 2011, 6:47 AM
As far as I can tell, your question is not actually specific to selecting rows in grids, but how to refer to nested components. In that case 'ref' is the answer:



var controlPanel = new Ext.Viewport({
title:'test',
items:[{
xtype:'tabpanel',
activeTab:0,
items:[
{
xtype:'grid',
store: statusStore,
ref: '../grid1'
}, {
xtype:'grid',
id:'tasks',
store: tasksStore,
title:'Tasks',
ref: '../grid2'
}
]
}]
});

// Then later to refer to the 2nd grid use:
controlPanel.grid2.getSelectionModel()....


P.S. Make sure you don't have trailing commas on property lists or you will break IE.

farnice
1 Oct 2011, 1:38 AM
Uberdude, thankyou very much for the answer
it still gives me "controlPanel.grid2 is undefined" though.
but I didn't know about the ref thing and it was a good hint. hope I can find what the problem is.