Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
685
Share ultratoolbarsmanager among ultragrids ?
posted

In my application, every UltraGrid has a "GridController" class that is responsible of the grid management ( Fill & Set datasource, InitializeLayout, all grid events, ...).

I want to set context menu to my grids. Some context menu options are the same for all grids ( Add rows, delete rows, ...) and some are grid specific.

Context menu options in a grid may also depends on which band is selected. Some row values may also affect which menu options is enabled/visible.

I want the context menu options to be accessible with keyboard shortcut. It is possible that while in a grid, a particular shortcut does something, and while in another grid, does something else.

Ok, now here is a specific situation:  I have a form with 2 ultratabs, each one having an UltraGrid. I would like each UltraGrid (GridController) to be responsible to create (at runtime) its context menu options, and before showing the context menu,assign the enabled/visible properties of tools depending on the selected rows.

Based on this scenario, I'm wondering what is the recommended way to create the ultratoolbarsmanager ?

1- Only one ultratoolbarsmanager created in the form and shared by both Ultragrid. In that case, I'm concerned about events conflict between the two grids (toolclick, shortcut,..).

2- Each Ultragrid (GridController) has it's own ultratoolbarsmanager created at run-time. In that case, what is the proper way to create ultratoolbarsmanager at run-time ? Does it absolutly need a container to be docked in ?

3- Any other suggestion is welcomed.

Thanks,

Guillaume

Parents
  • 44743
    Verified Answer
    posted

    I would recommend using one toolbars manager. Assign each grid the same popup menu as their context menu. In the BeforeToolDropdown event of the toolbars manager, check the SourceControl of the event args. If it is one of you grids, call off to a method on that grid's GridController and pass it the PopupMenuTool instance on the Tool property of the event args. This method on the GridController should populate the Tools collection of the PopupMenuTool based on the grid it controls as well as it's current state. As for handling shortcut keys, you can handle the BeforeShortcutKeyProcessed event on the toolbars manager to enable/disable any tools necessary for the currently active grid. In the ToolClick event, you would probably want to determine the currently active grid again and call off to tool click processing code defined on it's GridController.

Reply Children