PDA

View Full Version : Roweditor + action column :/



Tim Toady
20 Dec 2010, 7:49 AM
Not sure how to handle this. I have an action column on a grid with a roweditor. If I click delete (my button in the action column) under the right circumstances the roweditor pops up. The button handler in the action column passes an event paramater and I am doing e.stopEvent() yet the roweditor is still popping up. I even tried rowEditor.stopEditing() after the stopEvent. Any ideas how I should handle this???



handler: function(grid, rowIndex, colIndex, item, e) {
var rec = grid.store.getAt(rowIndex);
grid.store.remove(rec);
grid.store.save();
e.stopEvent();
rowEditor.stopEditing();
}
Thanks

Edit-----
I noticed the e.browserEvent.type is "mouseout"
Is that normal?

Tim Toady
21 Dec 2010, 5:16 AM
Any ideas?? I ended up implementing a really hacky solution. I added a property to the event object and modified the roweditor to check for it. I would rather not do it this way.

Condor
21 Dec 2010, 5:30 AM
I would do it the other way around and modify the roweditor so it doesn't start when an action column was clicked:

var editor = new Ext.ux.grid.RowEditor({
...
onRowClick: function(g, rowIndex, e) {
var colIndex = g.getView().getCellIndex(e.getTarget());
if (colIndex !== false) {
var column = g.getColumnModel().getColumnAt(colIndex);
if (column instanceof Ext.grid.ActionColumn) {
return;
}
}
this.constructor.prototype.onRowClick.apply(this, arguments);
}
});

Animal
21 Dec 2010, 5:37 AM
Try returning false.

It's not the browser event that you need to halt, it's the GridView's event broadcasting cascade. I'd have to get back into the code to see at which point either gets control.

While debugging, the act of observing clobbers the browser's singleton object, so that's a problem. You need to set the breakpoint after any data have been collected from the event.

Tim Toady
21 Dec 2010, 6:32 AM
@Condor
I didn't even think about attacking it from that direction thanks. It seems to work well (though I think you meant findCellIndex? getCellIndex wasn't finding anything). I definitely prefer your solution to my hijacking of the event object heh.

@animal
I tried returning false from the action columns button handler and it still seemed to have the issue. I looked into the code for a while yesterday I but didn't have a thorough enough understanding to figure out how to handle it in this situation.

Thank you both for your responses.

Animal
21 Dec 2010, 1:31 PM
Yes, I just looked at the GridView's event distributing code.

It fires the cellclick event before sending off to the ColumnModel for it to process its click handling, so the RowEditor, listening for cellclick gets in there first. So Condor is correct, the RowEditor should not edit if an ActionColumn was clicked on.

I think this thread should be moved to bugs for a fix to go into 3.4, and also so that the 4.0 RowEditor gets the benefit.

bee
2 Sep 2011, 7:04 AM
This code doesn't work for ExtJS 4.0 rowediting. Please let us know how to work for EXTJS 4.0