1. Summary
For programmatic Sidebar selection we have support for selectItem in CLAPI. The method accepts the menu guid as parameter and returns a Promise object. If the menu element is at a lower level then the method will initially expand and load all the levels before selecting the menu item.
2. Step by Step Guide
2.1 Create a Menu Structure
Create a Menu structure for the Sidebar and note the Menu GUID
3.2 Write Logic
In order to programatically select the entry in the sidebar you can use a function like the next one.
async function handleButtonClick() {
await mySidebar.selectItem("e40d2fba-8d04-ff91-9114-36c7e05afa68");
// do something after selecting Item
// check if some items is visible in Sidebar
const isItemVisible = mySlidebar.isItemVisible("e40d2fba-8d04-ff91-9114-36c7e05afa68");
// Collapse item
await mySidebar.collapseItem("e40d2fba-8d04-ff91-9114-36c7e05afa68");
await mySidebar.expandItem("e40d2fba-8d04-ff91-9114-36c7e05afa68");
}
3.3 Debug
For easy debugging in console you can find your Sidebar object by name from Root and select your item.
akioma.swat.Root.getObject('SimpleSwatSidebar').selectItem("c7965089-317d-3b83-9614-ea50686a10ce");
3. Documentation
To find more information and all the possibilities available, you can check the following documentation.
Back to Use Cases
Back to Home Page