Current Setup
I have a RadGrid and only want to provide a header context menu with an option to show/hide columns.
HeaderContextMenus are enabled and disabled grouping such that the only menu item that appears is the 'Columns' menu item which I've renamed. Please see the attached screenshot headercontextmenu_singleitem.png to get an idea of how the context menu appears when right-clicked. I have a javascript method that is applied to the client event OnHeaderMenuShowing. This is what I'm using to rename my 'Columns' column and do some other formatting.
What I Would Like to Do
In short I would like to only show the list of columns with checkboxes to show/hide, nothing more. I am checking in the javascript OnHeaderMenuShowing to see how many items I have in my main level menu. If only 1 item I want to only show the child popout menu which lists the columns with the checkboxes to show/hide columns.
I have managed to simulate this by setting the groupSettings offsetX and offsetY for the 'Columns' menu item to cause it to move over the main menu and setting the menu clickToOpen to true. (see screenshot headercontextmenu_singleitem_exampleonlychildshowing.png) This is more a hack and unfortunately inconsistent. After I left click on the page and right click again the menu does not appear in the same place. Multiple left clicks (on other columns) works correctly. I also cannot seem to turn off the expand and collapse animations.
Sample for moving the child menu when 1 item:
Sample for setting animations:
Thanks in advance for any suggestions.
I have a RadGrid and only want to provide a header context menu with an option to show/hide columns.
HeaderContextMenus are enabled and disabled grouping such that the only menu item that appears is the 'Columns' menu item which I've renamed. Please see the attached screenshot headercontextmenu_singleitem.png to get an idea of how the context menu appears when right-clicked. I have a javascript method that is applied to the client event OnHeaderMenuShowing. This is what I'm using to rename my 'Columns' column and do some other formatting.
What I Would Like to Do
In short I would like to only show the list of columns with checkboxes to show/hide, nothing more. I am checking in the javascript OnHeaderMenuShowing to see how many items I have in my main level menu. If only 1 item I want to only show the child popout menu which lists the columns with the checkboxes to show/hide columns.
if
(args.get_menu().get_items()._array.length == 1) {
// do something here when only 1 item
}
I have managed to simulate this by setting the groupSettings offsetX and offsetY for the 'Columns' menu item to cause it to move over the main menu and setting the menu clickToOpen to true. (see screenshot headercontextmenu_singleitem_exampleonlychildshowing.png) This is more a hack and unfortunately inconsistent. After I left click on the page and right click again the menu does not appear in the same place. Multiple left clicks (on other columns) works correctly. I also cannot seem to turn off the expand and collapse animations.
Sample for moving the child menu when 1 item:
if
(items._array.length == 1) {
items._parent.set_clickToOpen(
true
);
args.get_menu().get_items().getItem(0).open();
args.get_menu().get_items().getItem(0)._groupSettings.set_offsetX(-188);
// static numbers for now
args.get_menu().get_items().getItem(0)._groupSettings.set_offsetY(-28);
}
Sample for setting animations:
args.get_menu().get_expandAnimation().set_type(
"None"
);
args.get_menu().get_collapseAnimation().set_type(
"None"
);
Thanks in advance for any suggestions.