This example illustrates how to show the context menu in a group footer and set a group summary in a column.
To implement a custom Context Menu in a group footer, it is necessary to use ASPxPopupMenu and fill its items like in the Context Menu of a grid’s footer.
For this, get the clicked column's index and applied summaries to show the menu's checked items. Then, get item visibility of the Context Menu in the grid's footer and apply it to the custom Context Menu items.
To show the Context Menu in ASPxGridView, enable ASPxGridView's ContextMenu setting.
To get the clicked column's index and applied summaries, handle ASPxGridView’s PreRender and BeforeGetCallBackResult events, build and send a custom class name to the client side by using the GridViewDataColumn.GroupFooterCellStyle.CssClass property. This property includes a custom class name that contains an index and applied summaries of the clicked column. Handle ASPxGridView's client-side ContextMenu event to get the CssClass name by using htmlEvent’s target.classname property. After the custom class name is obtained, show a popup menu under the mouse pointer.
After that, handle ASPxClientPopupMenu's client-side PopUp event. Set the visibility and a checked state of menu items.
To set a checked state of a menu item, use applied summaries that were obtained earlier.
To set the visibility of menu items like in the menu of the grid’s footer, do the following:
- Use the private ASPxClientGridView.GetFooterContextMenu method to get footer menu item information;
- Iterate through all menu items;
- Use the private ASPxClientGridView.GetItemServerState method to get a footer menu item's visibility and apply it to a custom menu item of the group footer.
Handle ASPxClientPopupMenu's client-side ItemClick event and send an ASPxGridView callback with a column’s field name where the menu is shown and a clicked item name as parameters. Handle ASPxGridView's CustomCallBack event, parse these parameters there and apply the summaries.
Note: The private ASPxClientGridView.GetFooterContextMenu and ASPxClientGridView.GetItemServerState methods are used internally. Thus, they can be deleted or modified at any time without notification. It is necessary to check an application where this approach is used on every update of DevExpress controls until the functionality to create summary in the group footer is implemented out of the box.
↧
How to show the Context Menu in a group footer and set a group summary in a column
↧