CreateHeaderContextMenu - cCJGrid
Creates and returns a context menu to be used for headers. Is called when the object is created.
Type: Function
Return Data Type: Handle
Syntax
Function CreateHeaderContextMenu Returns Handle
Call Example
Get CreateHeaderContextMenu to HandleVariable
Description
When a grid is created, it needs to create a default header context menu to be used when a user right clicks on a header. This context menu is created in CreateHeaderContextMenu, which is called inside of the object's constructor. CreateHeaderContextMenu returns the handle of the object, which is set in phoHeaderContextMenu.
By making this a function, it provides a hook for developers to augment so they can create their own context menus.
The default header context menu allows you to invoke the field chooser and restore your header configuration (width, order and hiding) back to the original object layout. Its CreateContextMenu looks like this:
Function CreateHeaderContextMenu Returns Handle
Handle hoMenu hoMenu1
Get Create (RefClass(cCJContextMenu)) to hoMenu
Get Create of hoMenu (RefClass(cCJGridFieldChooserMenuItem)) to hoMenu1
Get Create of hoMenu (RefClass(cCJGridRestoreLayoutMenuItem)) to hoMenu1
Set pbControlBeginGroup of hoMenu1 to True
Function_Return hoMenu
End_Function
The context menu handle stored in phoHeaderContextMenu is the default menu that will be used. It is possible to choose to use a different header context menu based on the column selected. When the user right clicks on a header column, phoHeaderContextMenu contains the handle of the context menu to be displayed. Before this menu is displayed the column function HeaderContextMenu is called. It is passed the value of phoHeaderContextMenu and it returns the object handle to actually be used. This allows grid column object to supply custom header context menus at the column level. See the cCJGridColumn HeaderContextMenu function for a complete description of the context menu display process.
This message can only be augmented in subclasses. If added to an object, it will not be called when the object is created.
Return Value
Returns a context menu handle to be used for headers.