jQuery UI Widgets › Forums › Navigation › Tree › Getting the selected item (from the original "source" constructor argument)
Tagged: javascript treeview, jQuery TreeView, jqxtree, Tree, TreeView
This topic contains 1 reply, has 2 voices, and was last updated by Peter Stoev 12 years, 5 months ago.
-
Author
-
March 26, 2012 at 6:50 pm Getting the selected item (from the original "source" constructor argument) #3049
Hello,
I am using jqxTree. When constructing the tree, each item in the “source” argument have the following attributes:
id, data, label, items
When an item is selected on the tree, I need to get its corresponding ID, as passed to the tree using the “source” argument: The label itself is insufficient for me (not unique in the tree).
After binding to the ‘select’ event and getting the selected item (with jqxTree(‘selectedItem’)), I thought I would get the original object (as passed to the “source” argument) but instead I get a different object with the same label but a different id (that starts with “treeItem”). No trace of “data” or the original “id” attribute.
My questions:
– Is it a bug?
– If not, how to obtain the ID of the selected tree item (as passed to the “source” argument)?Thanks,
B.
March 27, 2012 at 3:32 am Getting the selected item (from the original "source" constructor argument) #3070Hi bouyoul,
‘data’ and ‘id’ properties are not supported when creating the jqxTree from object. To use an unique id, use the ‘value’ property.
For example:
var source = [ { icon: "../../images/mailIcon.png", label: "Mail", value: 'blue', 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" }, ];// create jqxTree$('#jqxTree').jqxTree({ source: source, width: '250px', checkboxes: true, theme: theme });var items = $('#jqxTree').jqxTree('getItems');var value = items[0].value;
The first item in the above code has ‘value’ property set to ‘blue’. After the initialization, I get this ‘value’ property from the jqxTree’s items collection.
Best Regards,
Peter StoevjQWidgets Team
http://www.jqwidgets.com -
AuthorPosts
You must be logged in to reply to this topic.