Included Menus in K2BMenu

Introduction

K2BMenu allows to include items in a menu defined outside the menu instance. This can be used two accomplish two goals:

  1. Separate the definition of a menu among several instances for better maintainability (for example, creating one menu definition for each module in the application and consolidating them in one "global" menu).
  2. Creating dynamic sections for a static menu procedure: the structure of the static procedure generated by K2BMenu instance is defined in design time, and cannot be modified in runtime. By including the result of executing a GeneXus procedure in the menu, the developer can create a section where items are loaded in runtime.

How it works

Referencing a K2BMenu instance

If you are in the first scenario, just add a reference to the K2BMenu instance in the Instance Property. By doing that, the included menu definition will be added to both static and initialization procedure.

Referencing a static menu load procedure

Step 1 - Creating a procedure to load the items

To include items in a menu that are not generated by K2BMenu pattern, the developer must first define a procedure object that return those items.

IncludedMenuParmRule
Included menu parm rule

The procedure's logic can contain anything: request to the user session, reading data from tables, etc. Items in the first level of the menu will be added as siblings to the siblings of the IncludedMenu node in the instance.

Step 2 - Adding an IncludedMenu node

To reference that procedure in the menu, the developer must create an IncludedMenu node in the desired location in the instance, leave the instance property in (none) and reference the procedure created in the first step in its "Static Menu Load Procedure" property.