Skip to main content

Adding Custom Menu Items

Follow these steps to remove standard menu items and add custom menu items:
  1. Retrieve and remove the standard sidebar menu items except for the login menu, add a rootMenuItem and configure the sidebar menu to open automatically when the app loads by running:
    // SidebarMenuModifier.ts
    export class SidebarMenuModifier {
    // ...
    constructor(private ivApi: ApiInterface) {
    const menuItems = this.ivApi.sidebarMenu.service.items;
    // Remove all entries besides the login one, and include the new nested one
    menuItems.splice(1, menuItems.length, this.rootMenuItem);
    // Automatically open the menu once finished modifying it
    ivApi.sidebarMenu.service.openMenu();
    }
    }
  2. Instantiate the SidebarMenuModifier in the main application file index.ts by running:
    // index.ts
    // ...
    import {SidebarMenuModifier} from "./SidebarMenuModifier";

    class TestApp
    {
    //..
    getApi("https://iviondemo.iv.navvis.com/")
    .then((iv: ApiInterface) => {
    this.ivApi = iv;
    new SidebarMenuModifier(iv);
    });
    }
    }
    // ..