Available from v. 1,5,11
Each page in the application can have a menu, which is statically created, and consists of page specific and custom menu items.
Data driven menu items, takes this to another level, where data on a page can control which items are enabled, and which are not, as well as which ones are promoted. The data can be either orders, order lines or lookup results.
The configuration needs to be done in two places.
- On the specific menu item on a given page.
- On the data send out from the backend.
An important note is that if a menu item references a specific data member, and that data member is not present in the data, then the menu item will not be visible. So the way to control visibility of a data member controlled menu item is to have the reference data member included in the data or not.
Page Configuration
A page configuration could look as follows, where the Open and ItemCrossReference menu items are set to be controlled by a data member.
<page id="Receive" type="OrderList" icon="mainmenureceive"> <title defaultValue="@{PageReceiveOrderListTitle}" /> <orderListConfiguration automaticOrderSelectionAfterFilter="true"> ... <list listId="Orders"> <!-- The enabled attribute is disregarded when the dataMember is setup. --> <open enabled="true" *dataMember="showOpenMenu"*/> </list> ... </orderListConfiguration> <actions> ... <open id="ItemCrossReference" dataMember="showCustomMenuItem"/> </actions> <!-- IMPORTANT: If the dataMember property is set on any menu item, defining number of promoted items here will be ignored. --> <menu numberOfPromotedItems="1"/> </page>
Data Configuration
The configuration needed on each individual data element, consists of a new xml element named menuItemStateConfigurations, that can contain an arbitrary list of elements that sum up the data members available for that given data element.
The element naming is up to the individual implementation, and just needs to match the name set in the dataMember="" attribute on the given menu item.
Valid attributes on the data member elements are as follows.
- promoted - Dictates that the menu item should be promoted, and the order in which it appears.
- enabled - Dictates if the menu item can be selected or if it is grayed out.
A data element could look as follows.
<baseOrderLine> ... <menuItemStateConfigurations> <!-- The element containing all menu item configurations. --> <showOpenMenu promoted="1" enabled="true"/> <!-- Show the menu item as the first promoted element and enabled. --> <showCustomMenuItem promoted="2" enabled="false"/> <!-- Show the menu item as the second promoted item, and make it disabled. --> </menuItemStateConfigurations> </baseOrderLine>