jQWidgets Forums
jQuery UI Widgets › Forums › Navigation › Tree › How to get the list of selected items?
Tagged: javascript tree, jquery tree, jQuery TreeView, jqxtree, Tree, TreeView, User Interface
This topic contains 7 replies, has 3 voices, and was last updated by Peter Stoev 12 years, 2 months ago.
-
Author
-
Hi,
I am newbie. I am implementing the tree control in my website.
I need to know how to get the list of selected items?Thanks for help!
KateHi Kate,
In order to get the selected item, you can use this code:
var selectedItem = $('#jqxTree').jqxTree('selectedItem');
The following code returns the selected item’s label:
var label = selectedItem.label
Hope this helps you.
Best Wishes,
Peter StoevjQWidgets Team
http://www.jqwidgets.comHi Peter,
How can I go through the tree elements and get the list of the checked elements ( the checkbox is checked)
Thanks!
Hi Kate,
To get the list of all checked items, you can use this code:
// get all items. var items = $("#jqxTree").jqxTree('getItems'); // save all checked items in checkedItems array. var checkedItems = new Array(); $.each(items, function () { if (this.checked) { checkedItems[checkedItems.length] = this.label; } });
Best Regards,
Peter StoevjQWidgets Team
http://www.jqwidgets.comThanks Peter. May I have one more question, please? I need to show the the list of checked items with the lable HTML control when the checkbox is checked.
Is there any event trigger when I click on the checkbox? Could you show me, please?
More details:
I did this one for the tree onclick even of the tree. Whenever, users click to select the item, the getSelectedItem will be triggered. This one works fine.I need to know how can I trigger an even when I check on the checkbox.
I appreciate your help!Kate
Hi Kate,
You can use the ‘checkchange’ event to trigger when the user checks/unchecks a tree item’s checkbox.
For example:
$("#jqxTree").bind("checkchange", function (event) { var args = event.args; // tree UI element. var element = args.element; // check state. var checkState = args.checked; // tree item. var item = $("#jqxTree").jqxTree('getItem', element); // tree label. var label = item.label;});
Best Regards,
Peter StoevjQWidgets Team
http://www.jqwidgets.comis it possible to get the child node only?
if the parent node is selected then the child node will all be selected, so is it possible to get only the child node and disregard the parent nodeHi ryan paul,
“checkChange” will be raised for any change in the checked state of any tree item.
Best Regards,
Peter StoevjQWidgets Team
http://www.jqwidgets.com -
AuthorPosts
You must be logged in to reply to this topic.