1 Context
In this task we will use the Panel switcher. To do this, we will write custom code and then connect it to a toolbar via a menu action.
2 Result
3 Step by step guide
3.1 Create the following three screens:
- "ItemOverview<_yourName>" and use the template "TrainingDay5_Template"-
- Copy the "ItemGrid" and "ItemForm" and name them "...<_yourName>"-
- Replace the placeholder objects with the DSO, Grid and Form
- "CustomerOverview <_yourName>" and use the template "TrainingDay5_Template"
- Copy the "CustomerGrid" and "CustomerForm" and name them "...<_yourName>"
- Replace the placeholder objects with the DSO, Grid and Form
- "PanelSwitcher <_yourName>"
- Put in the “SimpleSwatPanelSwitcher” on panel “A” and select “Save”
- Select the “SimpleSwatPanelSwitcher” in the "Preview" section and search for the attribute “viewName” in the “Attributes” section,
- Insert the name of the default screen, which should be displayed by launching the screen. In our case is “CustomerOverview<_yourName>” screen and select “Save”
- Select the screen and search in the “Attributes” section for the following attributes and populate them (do not forget to save them after, by hitting “Save”):
- “titleShort” -> “PanelSwitcher”-
- “EventNamespace” -> “#”
3.2 Create the function in typescript
- Select “</> Open events file” to create a new javaScript class
- Now please view the code, then press “Strg + S” to compile your changes.
export function <yourFunctionName>(eventSource: akioma.swat.Toolbar) {
eventSource.window.getFirstChildByType('panelSwitcher').controller.switchView('SCREENNAME FOR PANEL ACTION');
}
export function <yourFunctionName>Back(eventSource: akioma.swat.Toolbar) {
eventSource.window.getFirstChildByType('panelSwitcher').controller.switchView('SCREENNAME FOR PANEL ACTION');
}
3.3 Create the menu functions and link them with the type script
- Navigate to “Design” -> “Actions and Menus” -> “Actions” and create the following two functions
- “PanelSwitcherFunction_<yourName>”
- Module: “MyAppModule”
- Icon: “fad fa-arrow-right”
- Action Type: “RUN” (This command means you activate/run a function)
- #.togglePanelSwitcheryourName(eventSource); → (This is the name of the typescript Function)
- “PanelSwitcherFunctionBack_<yourName>”
- Module: “MyAppModule”
- Icon: “fad fa-arrow-left”
- Action Type: “RUN”
- #.togglePanelSwitcherBackyourName(eventSource); → (This is the name of the typescript Function)
3.4 Create a menu structure
- Navigate to “Design” -> “Actions and Menus” -> “Menus” and toggle the checkbox “Show root menus” and select the “Build.One Application”
- Select in the ribbons the button “Add as sublevel” and fill in the “MenuName” -> “PanelSwitcher_<yourName>” and the “Menu Structure Code” -> “PanelSwitcher_<yourName>” and select “Save”
- Select your newly created “PanelSwitcher_<yourName>” folder, in the dropdown above select the type “Item” and click again on “Add as sublevel”. Fill in a name as “Next Page” and insert the function “PanelSwitcherFunction_<yourName>” and select “Save”
- Execute step 9 above again for the other function “PanelSwitcherFunctionBack_<yourName>” and fill in the name as “Back”. Now copy the menu structure code of the “PanelSwitcher_<yourName>” folder
3.5 Add the toolbar with the functions to your screen
- Navigate back to the Screen Designer of your panel switcher screenÂ
- Search in the section ”Browse catalog of objects” for the “SimpleSwatToolbar” and add it to your screen above the panel switcher and select “Save”
- Select the toolbar and search in the “Attributes” section for the attribute “ToolBarKey”, then fill in the previously copied menu structure code and select “Save”
- Empty the cache and hard reload your screen
- Launch the screen to see the result. With the toolbar buttons you now should be able to switch between the panels
4 Explanation
In this exercise we repeated everything we had learnt.
- We created some screens
- create some custom code
- execute this custom code using a menu function
- create a menu structure for our functions
- we link them all together in our screen