PDA

View Full Version : [4.0.0] Disable/Enable Grid grouping feature while groupingmenu disabled



cntx
28 Apr 2011, 11:31 PM
Hey,

i have added a grouping feature to a Grid with enableGroupingMenu: false.
If i try to manually deaktivate the feature, ive getting an error that the groupingMenuItem is undefined.

This happens because the enable/disable functions dont check if there IS a groupingMenuItem.

in ext-debug line 77760

These functions should check if the menu is disabled by default.


enable: function() { var me = this,
view = me.view,
store = view.store,
groupToggleMenuItem;


if (me.lastGroupIndex) {
store.group(me.lastGroupIndex);
}
me.callParent();
if(me.enableGroupingMenu) {

groupToggleMenuItem = me.view.headerCt.getMenu().down('#groupToggleMenuItem');
groupToggleMenuItem.setChecked(true, true);
}

view.refresh();
},



disable: function() {
var me = this,
view = me.view,
store = view.store,
groupToggleMenuItem,
lastGroup;

lastGroup = store.groupers.first();
if (lastGroup) {
me.lastGroupIndex = lastGroup.property;
store.groupers.clear();
}

me.callParent();
if(me.enableGroupingMenu) {

groupToggleMenuItem = me.view.headerCt.getMenu().down('#groupToggleMenuItem');
groupToggleMenuItem.setChecked(true, true);
groupToggleMenuItem.setChecked(false, true);
}

view.refresh();
}
Right now for a workaround ive come along with smt like this:


var groupingFeature = Ext.create('Ext.grid.feature.Grouping',{
...

enableGroupingMenu: false,

enable: function() {
var me = this,
view = me.view,
store = view.store,
groupToggleMenuItem;

if (me.lastGroupIndex) {
store.group(me.lastGroupIndex);
}
if(me.enableGroupingMenu) {
groupToggleMenuItem = me.view.headerCt.getMenu().down('#groupToggleMenuItem');
groupToggleMenuItem.setChecked(true, true);
}
view.refresh();
},
disable: function() {
var me = this,
view = me.view,
store = view.store,
groupToggleMenuItem,
lastGroup;

lastGroup = store.groupers.first();
if (lastGroup) {
me.lastGroupIndex = lastGroup.property;
store.groupers.clear();
}

if(me.enableGroupingMenu) {
groupToggleMenuItem = me.view.headerCt.getMenu().down('#groupToggleMenuItem');
groupToggleMenuItem.setChecked(true, true);
groupToggleMenuItem.setChecked(false, true);
}
view.refresh();
}
});

greets cntx