Click here to Skip to main content
15,891,316 members
Please Sign up or sign in to vote.
3.00/5 (1 vote)
See more:
hi my project is

i have to create id, parent id , Name in database

this is my database

id    Parentid   Name
---------------------
1       0         A
2       1         B
3       1         C
4       0         D
5       4         E
6       4         F
7       0         G


now i should get output as

A    D     G
------------
B    E
C    F

if i add any more main menus are sub menus automatically it should take.

i have used json my code is

this is my view page
---------------------
JavaScript
script type="text/javascript">
    var url = '/home/get'
    $.ajax({ type: "get",
        url: url,
        datatype: "json",
        error: function (xhr, status, error) {
            alert(error);
        },
        success: function (json) {
            var g = json.st.length;
           // var h = json.r.length;
            alert("displaying values: " + g);
            var menu = new dhtmlXMenuObject("menuObj");
          //  menu.attachEvent("onTouch", menuTouch);
            {
                for (i = ((json.st.length) - 1); i >= 0; i--) {
                    alert("displayed data: " + json.st);
                    menu.addNewSibling(null, "a", json.st[i], false);
                    {
                        // if (json.st.id == json.st.Parentid)
                        if(json.r[i].id == json.r[i].Parentid)
                           // for (i = ((json.r.length) - 1); i >= 0; i++)
                            {
                                menu.addNewChild("a", 0, "new", json.r[i], false);
                            }
                            else
                            {
                                // menu.addNewSeparator("new");
                                menu.addNewChild("b", 0, "file", json.r[i], false);
                            }
                         alert("displaying data: " + json.r);
                    }
                }
        }
    });
</script>
</head>


but im getting out put

A    D     G
------------
B    
C    

i am not getting the secong main menu item

i couldn't able to get submenus from main menu D G etccc


so plaese suggest if there is any step to proceed

Thank you
Posted
Updated 19-May-12 1:23am
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900