jQWidgets Forums

jQuery UI Widgets Forums Navigation Tree XML Tree with Empty Nodes

This topic contains 4 replies, has 2 voices, and was last updated by  shimmoril 12 years, 9 months ago.

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
  • XML Tree with Empty Nodes #7168

    shimmoril
    Participant

    I am populating a three level tree from XML data. In some instances the second (or third) level item may not exist for a parent. When this occurs, I get a blank line with an expand/collapse arrow, and then a third level node with the text ‘Item’.

    What I need to happen is for the nearest parent (ie. first level if the second is empty; second level if the third is empty) to not have an expand/collapse arrow at all. How can I configure this?

    Sample XML:

    <Roles>
    <Role>
    <RoleID>16</RoleID>
    <RoleName>Role C</RoleName>
    <Certifications>
    <Certification>
    <CertificationName>Certification 2</CertificationName>
    <CertificationType>Optional</CertificationType>
    </Certification>
    </Certifications>
    </Role>
    <Role>
    <RoleID>16</RoleID>
    <RoleName>Role C</RoleName>
    <Certifications>
    <Certification>
    <CertificationName/>
    <CertificationType/>
    </Certification>
    </Certifications>
    </Role>
    </Roles>

    Also, can you provide the XML sample data used for the XML Tree example? It would help me figure out exactly what is happening there if I could see the data structure.

    XML Tree with Empty Nodes #7171

    shimmoril
    Participant

    Another question: Is it possible to have one static item in the tree (at the top say), with all the other items coming from the XML?

    XML Tree with Empty Nodes #7176

    Peter Stoev
    Keymaster

    Hi shimmoril,

    There’s no built in solution for your scenario. You will need to build a similar source object as below from your XML Data Source and then you will be able to display it in the jqxTree.

      var source = [
    { icon: "../../images/mailIcon.png", label: "Mail", expanded: true, items: [
    { icon: "../../images/calendarIcon.png", label: "Calendar" },
    { icon: "../../images/contactsIcon.png", label: "Contacts", selected: true }
    ]
    },
    { icon: "../../images/folder.png", label: "Inbox", expanded: true, items: [
    { icon: "../../images/folder.png", label: "Admin" },
    { icon: "../../images/folder.png", label: "Corporate" },
    { icon: "../../images/folder.png", label: "Finance" },
    { icon: "../../images/folder.png", label: "Other" },
    ]
    },
    { icon: "../../images/recycle.png", label: "Deleted Items" },
    { icon: "../../images/notesIcon.png", label: "Notes" },
    { iconsize: 14, icon: "../../images/settings.png", label: "Settings" },
    { icon: "../../images/favorites.png", label: "Favorites" },
    ];

    To dynamically add new items, use the ‘addTo’ method.

     $('#jqxTree').jqxTree('addTo', { label: 'Item' });

    Best Regards,
    Peter Stoev

    jQWidgets Team
    http://www.jqwidgets.com

    XML Tree with Empty Nodes #7213

    shimmoril
    Participant

    Would the JQXMenu be able to handle parents that may or may not have children? Creating a source in the manner you’ve suggested would be very time-prohibitive – my XML is actually (up-to) 4 levels deep.

    XML Tree with Empty Nodes #7215

    shimmoril
    Participant

    Would the JQXMenu be able to handle parents that may or may not have children? Creating a source in the manner you’ve suggested would be very time-prohibitive – my XML is actually (up-to) 4 levels deep.

    Also, would you consider adding this functionality to a future release?

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

You must be logged in to reply to this topic.