This Tutorial explains how to define and use a Ribbon in the SWAT UX, like in this Screen:
First, you need to add a Ribbon control to your screen, using the SWAT Screendesigner. As the Ribbon is quite generic, you can just use the Object-Master “SimpleSwatRibbon”, which is shipped with the Framework, instead of creating your own Ribbon-Masters.
Just add the SimpleSwatRibbon object to your Screen like any other Object, by opening the “Add” dialog, and drag&drop from the Grid onto a panel in your screen:
This will add the Ribbon control to your screen, but at runtime it will be empty. To actually see a Ribbon at runtime, you need to provide a Ribbon definition. This is done by the “ToolbarKey” Attribute of the Ribbon control. At runtime, this will tell the Ribbon which Menu-Structure it should use to build the actual Ribbon on the screen. You can specify a JSON file here, which must be available on the Backend, e.g. “uicache/myRibbonDefinition.json”. This can be useful for testing, or for quick prototyping.
Most of the time, however, you will use a SmartComponentLibrary Menustructure to define your Ribbon. This can be done using a “#” as the prefix in your ToolbarKey Attribute, which will tell the Ribbon that the part after the “#” is the Code of a SCL Menustructure, e.g. “#MyRibbonDefinition”:
In order to use a Menustructure for a Ribbon, it needs to have the correct structure.
A Ribbon consists of:´
Optionally, below the “Root” node and above the Block nodes, there can be an additional level of menu-nodes. These Menu-nodes will be rendered as Ribbon-Tabs, and therefore must have the Menu-Style set to “Ribbon Tab”
Attributes for Ribbon Blocks
You can define Attributes for whole Ribbon blocks, e.g. to conditionally define their visibility. For this, you must set the Parameter Type to “SWAT Ribbon”:
The “visibility Rules” Attribute allows to dynamically control the visibility of whole Ribbon blocks. E.g.: {"currentPage": "1,!*"}
This value for the visibility Rules Attribute makes the corresponding Ribbon-Block only on page 1 visible, and hides it for all other pages.
The “Menu Style” and Parameter type are not that important, because the actual UI representation is mostly dependent on the definition of the screen and the Menustructure. E.g., if you add a “SimpleSwatRibbon” to your screen, the menustructure referenced in the “ToolbarKey” attribute will be rendered as a Ribbon. If instead you use a “SimpleSwatToolbar” object (which also has a “Toolbarkey” Attribute), the same structure will be rendered as a Toolbar. |