jQWidgets Forums

jQuery UI Widgets Forums Navigation Tree Dynamic Hierarchal json data

This topic contains 3 replies, has 2 voices, and was last updated by  ivailo 9 years, 3 months ago.

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
  • Dynamic Hierarchal json data #81340

    mskerbitz
    Participant

    I’m trying to create a tree with this json data. Each space could have any number of levels. I see my data get returned in my controller (MVC) but the tree does not populate. Var “records” in the tree code comes back null. Help?

    SPCSpaceID SpaceText ParentSPCSpaceID
    8095 Test Space 5
    8096 Test Complex 8095
    8097 Test Dorm1 8096
    8098 Test Room1 8097
    8099 Test Room2 8097
    8103 Test Dorm2 8096
    8104 Test Wing1 8103
    8106 Test Room7 8104
    8107 Test Room8 8104

    function PopTree() {

    var source =
    {
    dataType: “json”,
    dataFields: [
    { name: ‘SPCSpaceID’ },
    { name: ‘ParentSPCSpaceID’ },
    { name: ‘SpaceText’ },

    ],
    id: ‘SPCSpaceID’,
    async: false,
    url: ‘ME/Search/GetSpace’
    };

    var dataAdapter = new $.jqx.dataAdapter(source);
    dataAdapter.dataBind();

    var records = dataAdapter.getRecordsHierarchy(‘SPCSpaceID’, ‘ParentSPCSpaceID’, ‘items’, [{ name: ‘SpaceText’, map: ‘label’ }]);
    $(‘#jqxWidget’).jqxTree({ source: records, width: ‘300px’ });

    };

    Dynamic Hierarchal json data #81359

    ivailo
    Participant

    Hi mskerbitz,

    We tested your code with localdata and it looks well.
    Here is a demo.

    Please check the format of the data returned from your url and check for errors in your console.
    Also please try to update to the latest version(4.0.0).

    Best Regards,
    Ivailo Ivanov

    jQWidgets Team
    http://www.jqwidgets.com

    Dynamic Hierarchal json data #81382

    mskerbitz
    Participant

    Thanks, for anyone who is wondering I changed the GetSpace method so it only returned those 3 specific fields not the whole model.

    Dynamic Hierarchal json data #81389

    ivailo
    Participant

    Hi mskerbitz,

    To check if the request is failed, you can use loadError callback of the dataAdapter.

    Best Regards,
    Ivailo Ivanov

    jQWidgets Team
    http://www.jqwidgets.com

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

You must be logged in to reply to this topic.