Logo

    Home

    Documentation

    Use Cases

    Training

    Applications

    Release Notes

    Change Sidebar selection programatically

    Change Sidebar selection programatically

    • 1. Summary
    • 2. Step by Step Guide
    • 2.1 Create a Menu Structure
    • 3.2 Write Logic
    • 3.3 Debug
    • 3. Documentation

    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 structureMenu structure for the SidebarSidebar 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.

    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.

    SidebarSidebar

    Menu structureMenu structure

    Back to Use CasesUse Cases

    Back to Home Page

    Logo
    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");
    
    }