PDA

View Full Version : getSelections() from bbar ... how to reference to the grid?



michiel
14 Jul 2010, 12:30 AM
Hiu guys,

I have set up a grid with a bbar and now I want one button to get the selected rows. The problem is how I can properly reference to the grid, when it doesn't have an id? Consider the following code:



var defaults = {
items: [{
xtype: 'grid',
store: results_store,
columns: [],
stripeRows: true,
viewConfig: {
forceFit: true,
onDataChange: function(){
this.cm.setConfig(this.ds.reader.jsonData.columns);
this.syncFocusEl(0);
}
},
bbar: new Ext.PagingToolbar({
items:[{
text: Lng.delete_selected_rows,
cls: 'x-btn-text-icon details',
handler: function() {
// Get selected rows here
}
}]
})
}]

};

// create config object
var cfg = Ext.apply({}, config, defaults);

// instantiate
var cmp = new Ext.Panel(cfg);


Any ideas?

Thanks, Michiel

Animal
14 Jul 2010, 12:36 AM
A top or bottom Toolbar's ownerCt is the Panel in which it is embedded.

michiel
14 Jul 2010, 1:11 AM
I see .. so then in this case, ownerCt should be the gridpanel, right?

If I try: this.ownerCt.getSelections() it results in an error though (this.ownerCt.getSelections is not a function).

fay
14 Jul 2010, 1:25 AM
getSelections() is a method of the grid's RowSelectionModel (http://www.sencha.com/deploy/dev/docs/?class=Ext.grid.RowSelectionModel).

beegeedee
14 Jul 2010, 4:13 AM
try this.ownerCt.getSelectionModel().getSelections()

Animal
14 Jul 2010, 4:14 AM
Not quite.

What do you think "this" is, by default, in the handler of a Button?

beegeedee
14 Jul 2010, 4:18 AM
well, if this was a reference to the grid rather than the PagingToolbar this.getSelectionModel().getSelections() would do the job. of course, if it was the selection mode, then this.getSelections() would do it. I guess it all depends on the scope of the function which would logically be the PagingToolbar but it may not be the case here.

Animal
14 Jul 2010, 4:36 AM
The default scope of a Button handler is the Button.