PDA

View Full Version : Change Grouping Grid Group Row Click Behavior



jurban
21 Jul 2009, 8:09 AM
I have a grouping grid. By default when you click (right or left) on any of the group level rows in the grid the group is expanded or collapsed. How could I change the behavior of these rows so that left clicking a grouping row selects it and right clicking will allow me to display a context menu that acts on the group row?

jurban
22 Jul 2009, 6:19 AM
Someone must have an idea how to do this.

Lukman
22 Jul 2009, 7:15 AM
override GroupingView's interceptMouse() function:


interceptMouse : function(e) {
var hd = e.getTarget('.x-grid-group-hd', this.mainBody);
if (hd){
e.stopEvent();
var group_id = hd.id.substr(0, hd.id.length - 3);
switch (e.button) {
case 0:
// handle left click
alert(group_id);
break;
case 2:
// handle right click
this.toggleGroup(group_id);
break;
}
}
}The left click handling is only partially implemented above. I think it takes a lot more manipulation of GroupingView, GroupingStore and SelectionModel to programmatically select all rows in particular group.

p/s: make sure you intercept 'contextmenu' event on the GridPanel to prevent browser right-click menu.

jurban
23 Jul 2009, 8:17 AM
I got all of it working but one thing. I can't prevent the browser context menu on the grouping rows. I tried killing the grid's context menu as follows:

grid.on('contextmenu', function(e)
{
e.stopEvent();
});
This did kill the browser context menu on the empty portion of the grid, but did not do anything about the browser context menu of the grouping rows.

Any suggestions how to kill the browser context menu for the grouping rows?

MD
23 Jul 2009, 9:09 AM
try e.preventDefault();

jurban
23 Jul 2009, 9:41 AM
Didn't work.

jurban
23 Jul 2009, 11:11 AM
FWIW: After using the debugger I discovered the gird contextmenu handler is NOT called when you right click on the grouping headers. Furthermore the only mouse event that interceptMouse gets is the mousedown. Calling e.stopEvent() does not cancel the browser event. So I am going to post this to the bug section.

medusadelft
18 Oct 2009, 9:18 AM
Is this fixed in 2.3.0? (Can't see when it is released... (hint hint to Ext Support Group :-? )

Edit:
Found another thread using a plugin (http://www.extjs.com/forum/showthread.php?t=63216)