Adding Custom Menu Items
  • 26 Jan 2024
  • 1 Minute to read
  • Dark
    Light
  • PDF

Adding Custom Menu Items

  • Dark
    Light
  • PDF

Article summary

Follow these steps to remove standard menu items and add custom menu items/

Procedure

  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);
          });
      }
    }
    // ..


Was this article helpful?

Changing your password will log you out immediately. Use the new password to log back in.
First name must have atleast 2 characters. Numbers and special characters are not allowed.
Last name must have atleast 1 characters. Numbers and special characters are not allowed.
Enter a valid email
Enter a valid password
Your profile has been successfully updated.