We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. (Last updated on : November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

How to create the menu items dynamically?

You can create the menu items dynamically by two ways.

  1. Using public methods like insert, insertBefore and insertAfter.
  2. Specifying the new data source to the menu.

By using public methods:

The public methods are applicable for all type of menus structure (“ul”, “JSON”, “template”).

The insert method:

The insert method is used to add the menu items as child to target nodes. This method contains two parameters. One is menu items collection (i.e., one or more menu items) that consists of collection of item to be added as child items for the target elements. Second one is target node collections that consists of collections of target element. It is not necessary to add the second parameter that is the target element. You can also specify the target for the new elements by using the parentId attribute.

Refer to the following code example that explains how to use insert method.

JS

 

The insertBefore method:

The insertBefore method adds the new/dynamically specified menu items before the specified target element. It requires two parameters. The parameter that you need to specify for this method, is same as the one that you specify for insert method.

Refer to the following code example for how to use inserBefore method.

JS

 

The insertAfter method:

The insertAfter method adds the new/dynamically specified menu items after the specified target element. It requires two parameters. The parameter that you need to specify for this method, is also same as the one that you specify for insert/insertbefore method.

Refer to the following code example for how to use insertAfter method.

JS

 

Specify the new data source:

You can create the menu items dynamically by specifying the data source at the runtime by using set model options. Refer to the following code example to specify it.

JS

 

Article ID: Published Date: Last Revised Date: Platform: Control:
4080 02/18/2015 02/18/2015 JavaScript ejMenu
Tags:
Did you find this information helpful?
Add Comment
You must log in to leave a comment

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon