Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to create sub child menu from a json
    primarykey
    data
    text
    <p>I created a horizontal menu from a json file. But I can't create the child and subchild. When I create the child of administrator it goes to home's child. My javascript file is</p> <pre><code>var data = [{ "menu":[ { "MenuId":1, "MenuName":"Home", "MenuLink":null, "Action":null, "Controller":null, "ParentID":null, "SortOrder":1, "ModuleId":null, "Menus":{ } }, { "MenuId":2, "MenuName":"New Transaction", "MenuLink":null, "Action":null, "Controller":null, "ParentID":null, "SortOrder":2, "ModuleId":null, "Menus":{ } }, { "MenuId":3, "MenuName":"Portfolio", "MenuLink":null, "Action":null, "Controller":null, "ParentID":null, "SortOrder":3, "ModuleId":null, "Menus":{ } }, { "MenuId":4, "MenuName":"Analytics", "MenuLink":null, "Action":null, "Controller":null, "ParentID":null, "SortOrder":4, "ModuleId":null, "Menus":{ } }, { "MenuId":5, "MenuName":"Instructions", "MenuLink":null, "Action":null, "Controller":null, "ParentID":null, "SortOrder":5, "ModuleId":null, "Menus":{ } }, { "MenuId":6, "MenuName":"Data Upload", "MenuLink":null, "Action":null, "Controller":null, "ParentID":null, "SortOrder":6, "ModuleId":null, "Menus":{ } }, { "MenuId":7, "MenuName":"Administration", "MenuLink":null, "Action":null, "Controller":null, "ParentID":null, "SortOrder":7, "ModuleId":null, "Menus":[ { "MenuId":8, "MenuName":"Masters", "MenuLink":null, "Action":null, "Controller":null, "ParentID":7, "SortOrder":1, "ModuleId":null, "Menus":[ { "MenuId":10, "MenuName":"Currency", "MenuLink":"/Currencies/Index", "Action":"Index", "Controller":"Currencies", "ParentID":8, "SortOrder":1, "ModuleId":null, "Menus":{ } }, { "MenuId":11, "MenuName":"Country", "MenuLink":"/Countries/Index", "Action":"Index", "Controller":"Countries", "ParentID":8, "SortOrder":2, "ModuleId":null, "Menus":{ } } ] }, { "MenuId":9, "MenuName":"User Management", "MenuLink":null, "Action":null, "Controller":null, "ParentID":7, "SortOrder":2, "ModuleId":null, "Menus":{ } } ] } ] } ]; $(function() { for(var i = 0, j = data[0].menu.length; i&lt;j; i++) { var root_menu = data[0].menu[i]; if(root_menu.hasOwnProperty("MenuId")) { $("#menu").append('&lt;li&gt;&lt;a href="#" class="parent-menu"&gt;' + root_menu.MenuName + '&lt;/a&gt;'); if(root_menu.hasOwnProperty("Menus") &amp;&amp; root_menu.Menus.length &gt; 0) { $("#menu li").append("&lt;ul class='child-list' id='menu_" + root_menu.MenuId + "'&gt;"); for(var n = 0, m = root_menu.Menus.length; n&lt;m; n++) { var sub_menu = root_menu.Menus[n]; if(sub_menu.hasOwnProperty("MenuId")) { $("#menu_" + root_menu.MenuId).append("&lt;li class='menu-child'&gt;&lt;a href='#'&gt;" + sub_menu.MenuName + "&lt;/a&gt;&lt;/li&gt;"); } } } $("#menu").append("&lt;/ul&gt;&lt;/li&gt;"); } } }); </code></pre> <p>You can check my code from <a href="http://jsfiddle.net/JcU4G/9/" rel="nofollow">http://jsfiddle.net/JcU4G/9/</a> Here the child also has a sub child. How can i arrange the child and sub child from a json file?</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload