PDA

View Full Version : can OnRowSelect extend to an expander?



sschmitt
23 Feb 2011, 1:34 PM
I have a grid with an onRowSelect event that goes to a different page.

I also have a Ext.grid.RowExpander on that row.

I want a click anywhere on the expanded row to trigger the onRowSelect. Right now, only a click on the top line (what you see before you expand) triggers the event.

Any creative ideas on how to do this?

sschmitt
23 Feb 2011, 4:14 PM
I solved this by inserting the same onclick event into my template.

It was poorly documented, but I discovered that while inside a template you can do {parent.whatever} to access a node higher up in the json hierarchy. That made it possible to get it done that way.

Condor
24 Feb 2011, 7:31 AM
A better way would have been to attach the same handler to the rowbodyclick event.

sschmitt
24 Feb 2011, 12:57 PM
Thanks for replying, but I couldn't get that to work. Here's the code:




Ext.apply(this, {
id: 'mydocsgrid',
frame: false,
border: false,
stripeRows: false,
hidden: true,
//Set to an empty store initially. the data for this grid will be loaded after the page is rendered
store: new Ext.data.Store({
reader: new Ext.data.JsonReader({
root: 'rows'
}, [])
}),
columns: [],
bbar: this.pagingBar,
plugins:[
this.expander,
this.searchField
],
sm: new Ext.grid.RowSelectionModel({
listeners: {
rowselect: this.onRowSelect,
rowbodyclick: this.onRowBodyClick,
scope: this
}
})
});

...

onRowSelect: function(sm, idx, r) {
alert(' onRowSelect works!');

},

onRowBodyClick: function(sm, idx, r) {
alert(' unfortunately, onRowBodyClick does not occur.');

}

Condor
24 Feb 2011, 11:39 PM
rowbodyclick is a grid event and not a selection model event.