sidenav
Since V1.1.0
Eager to get started ? Check out this video intro
Sidenav is a 4-levels depth navigation component. Is a side menu with selectable and collapsible nested menu items. The user can select or expand one menu item per time; a selected menu item is automatically expanded. The developer can control the sidenav component programmatically by editing the element's runtime properties and using the element's API. The sidenav can slide in/out to the left side or to the right side. The component can be used as a tablesspanel container, having a containedForm on the side of the menu which animates together with the menu. The component is fully stylable with CSS3.
Content under construction
Table of contents
Getting Started
Use the api setRootMenuItems to populate the sidenav with Menu Items. You can nest Menu Items up to 4 levels depth.
The method setRootMenuItems requires an Array of Menu Item object.
Menu Item
The menu item is a JSON object representing an item in the sidenav. A menu item may nest other menu items. A menu item may be also used as divider, which is nothing else then a line separating the menu item above and below, in this case all other properties of the menu item are ignored.
Menu Item properties can be found here.
This is a menu item with 2 sub menu items
This menu item is instead rendered as a divider
Update a Menu Item
To update a menu item you should get the menu item object using the component's API getMenuItem, any change to the returned object will be reflected on the sidenav component.
Example
Updating an old reference of the menuItem which has not been retrieved via API it won't be possible.
Don't do this:
Instead do
Styling Sidenav
There are several CSS class selectors you can use for fine-grained styling of the sidenav component.
element selector | summary |
---|---|
.svy-extra-sidenav | the root element, style is applied to the sidenav and to the tablesspanel |
.svy-sidenav | style the whole sidenav component |
.svy-sidenav-tablesspanel | style the tablesspanel container |
.svy-sidenav-menu | style the menu and all it's content |
.svy-sidenav-dropdown | style the dropdown list in each menu level |
.svy-sidenav-item | style the menu item in dropdown list |
.svy-sidenav-collapse-icon | stlye the collapse/expand icon |
.svy-sidenav-divider | style the divider |
.svy-navitem-selected | style the selected menu item |
.svy-sidenav-collapsed | style the menu item expanded |
.svy-sidenav-disabled | style the menu item disabled |
.svy-slide-out | stlye the nav menu when is closed |
To style a specif element on a specific level combine the element element selector above with the level selector below
level selector | summary |
---|---|
.sn-level-1 | the elements in root level |
.sn-level-2 | the elements in the second level |
.sn-level-3 | the elements in the third level |
.sn-level-4 | the elements in the fourth level |
Examples
Sidenav Properties
Sidenav properties can be found here.
Sidenav Events
Sidenav events can be found here.
Sidenav API
Sidenav API methods can be found here.
Add a menu item. The menu is added as sub Menu Item if a menuItemId is provided, otherwise is added in root. If index is provided the menu is added at the specified index position, otherwise is added as last element. Return false if menuItemId cannot be found.
Example
Remove all the menu items. If depth is specified removes all the menu items at depth. If depth is equal to 1 all roots will be removed. Default depth is 1.
Example
Returns the menu item object.
Returns the parent menu item object of the menu item with id menuItemId. Nothing is returned if the menu item is in the root menu.
Returns the root menu items.
Returns the selected menu item.
Get the menuItems of the menu item with id 'menuItemId'.
Returns true if the menuItem and all it's ancestors are enabled. Return false if menuItemId cannot be found or is disabled.
NOTE: The method returns false if any ancestor of the menuItem is not enabled; if the property enabled of the menuItem is set to true, but has a parent with the enabled property set to false, then isMenuItemEnabled returns false.
Returns true if the menuItem is expanded.
Enable or disable the menu item. Return false if menuItemId cannot be found.
Return false if menuItemId cannot be found or is disabled.
Init the menu setting the root menuItems.
Example
Select the menu item with the given id. If level is provided search is optimized since it will search only within the descendant of the selected menuItem at level. For example if a root menuItem is selected and level is equal 2 search only in the subMenuItems of the selected root. Return false if menuItemId cannot be found or is disabled.
Set the menuItems as sub menu items of the menu item with id 'menuItemId' Return false if menuItemId cannot be found.
Example
Remove the menu item and all it's subMenuItems from the tree. Return false if menuItemId cannot be found.
Remove all the sub menu items of the menu item with id 'menuItemId'. Return false if menuItemId cannot be found.
Related Articles
The following articles are recommended for additional reading
Last updated