jQuery UI Widgets Forums Navigation Tree Problem retrieving item collection

This topic contains 2 replies, has 2 voices, and was last updated by  iao93 8 years, 10 months ago.

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
  • Problem retrieving item collection #57104

    iao93
    Participant

    Hi,

    Am having an issue with retrieving the child nodes of my tree-view. I’m thinking there might be something wrong with the JSON string format that I’m returning from the server.

    Code:

    
    var source =
                    {
                        datatype: "json",
                        async: false,
                        datafields: [
                            { name: 'id' },
                            { name: 'parentid' },
                            { name: 'label' }
    
                        ],
                        items: [
                            { name: 'id' },
                            { name: 'parentid' },
                            { name: 'label' }
    
                        ],
                        id: 'id',
                        url: 'Charts.aspx?callback=GetTreeData'
                    };
    
                var dataAdapter = new $.jqx.dataAdapter(source);
                dataAdapter.dataBind();
                var records = dataAdapter.getRecordsHierarchy("id", "parentid", "items");
                $('#jqxWidget').jqxTree({ source: records, width: '300px' });

    This is the JSON string I’m receiving from the server:

    [{“id”:”178″,”parentid”:”-1″,”label”:”Parent Item 1″,”value”:null,”icon”:null,”items”:[{“id”:”78″,”parentid”:”178″,”label”:”Child Item 1″,”value”:null,”icon”:null,”items”:null},{“id”:”79″,”parentid”:”178″,”label”:”Child Item 2″,”value”:null,”icon”:null,”items”:null} …… and so on…

    My tree view is only displaying the root nodes but not any child nodes.

    Kindly advise me on what I’m doing wrong.
    Thank you in Advance,
    AJ

    Problem retrieving item collection #57143

    Dimitar
    Participant

    Hello AJ,

    In the demo JSON Tree you can see what your JSON source should look like to successfully create a tree. The main difference from your approach is not having “items” but only a reference to the parent: “parentid”.

    Best Regards,
    Dimitar

    jQWidgets team
    http://www.jqwidgets.com/

    Problem retrieving item collection #57147

    iao93
    Participant

    Thank you Dimitar,

    Got it working now!

    Warmest,
    AJ

Viewing 3 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic.