jQWidgets Forums
jQuery UI Widgets › Forums › Navigation › Tree › XML Tree with Empty Nodes
Tagged: tree xml emptynode
This topic contains 4 replies, has 2 voices, and was last updated by shimmoril 12 years, 9 months ago.
-
Author
-
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.
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?
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 StoevjQWidgets Team
http://www.jqwidgets.comWould 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.
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?
-
AuthorPosts
You must be logged in to reply to this topic.