View Full Version : programmatically Show/Hide groups in GroupingView

11 Jan 2012, 5:05 PM
Hey ppl,
I have a grid with a groupingView and I know there's the option to toggle Show In Groups in the column menus but is there a way to programmatically trigger it?

I tried extending GroupingView with this method:

showGroups: function (checked) {
var mi = this.hmenu.items.get(this.hmenu.items.findIndex('itemId', 'showGroups'));
if (mi && mi.checked != checked) {
mi.checked = checked;
this.onShowGroupsClick(mi, checked);

And it sorta works, but it doesn't change the checkbox state in the column menu. I.e. if I call grid.getView().showGroups(false), it will change the view to hide the groups, but it won't change the menu item's checkbox. Is there a built-in method that will do this already or a better way to accomplish it?

Any help is appreciated.

12 Jan 2012, 6:35 AM
Ok I figured out how to do it. Here is the updated method:

showGroups: function (checked) {
var mi = this.hmenu.items.get('showGroups');
mi && mi.setChecked(checked);

I needed to use the setChecked() method.