Chapter 13. Context Menus

Chapter 13. Context Menus

Detail windows and task panes discussed above are shown in the SelectionChange event.

We can add such queries and much more to the context menu.

Let's add the following configuration to the EventHandlers table (two lines at the bottom):

Sample of the ContextMenu handlers

Contrary to the SelectionChange handler, we have specified columns. So, context menus are shown for columns.

Also, we have directly specified select columns in the HANDLER_CODE. The plus sign defines the sort order.

@Company and @Item fields are used in the WHERE clause to filter output data using current row values.

Let's select the payments sheet, click Reload, Reload Data and Configuration, and right click on a company cell:

Sample of the Excel context menu configured with the EventHandlers table


When we click on the dbo69.Payments item, the add-in shows the window like this:

Sample of the drill-down queries from the Excel context menu

You see rows for Rose, Inc. You can click on the status line to check the generated SQL:

Click on the status line to check the generated SQL

Let's right click on any Revenue item cell and click on the dbo69.Payments item. We will see item payments.

Sample of the drill-down queries from the Excel context menu (by an item)



As we learned above, the SelectionChange and ContextMenu handlers are nearly the same.

They get parameters from the columns of the active row. They differ by the EVENT_NAME configuration.

However, the ContextMenu handlers support additional configuration parameters like MENU_ORDER and EDIT_PARAMETERS and allow using much more handler types in the HANDLER_TYPE field.

You can configure executing stored procedures, SQL codes, macros, CMD commands, opening URLs.

Use the MenuSeparator type to separate menu items.

This website is using cookies. By continuing to browse, you give us your consent to our use of cookies as explained in our Cookie Policy.OK