jQuery UI Widgets › Forums › Navigation › Tree › Init TreeNodes with CheckState
This topic contains 4 replies, has 2 voices, and was last updated by Pei Hu 12 years, 9 months ago.
-
Author
-
I want init the tree with its treenodes having orignal checkstate by the “source” option. but it seems “checked” property is not supported.
something like:
var source = [
{ label: “Item 1”, expanded: true, items: [
{ label: “Item 1.1”, checked: true },
{ label: “Item 1.2”, selected: true, cheked: true }
]
},
{ label: “Item 2” },
{ label: “Item 3” },
{ label: “Item 4”, items: [
{ label: “Item 4.1” },
{ label: “Item 4.2” }
]
},
{ label: “Item 5” },
{ label: “Item 6” },
{ label: “Item 7” }
];
So how should I do?My english is not good, hope you understand!
Thanks for help!
HuHi Pei Hu,
Thank you for writing.
You can use the ‘checkItem’ method to check an item.
For example:
var items = $('#jqxTree').jqxTree('getItems');var firstElement = items[0].element;$('#jqxTree').jqxTree('checkItem', firstElement, true);
Best Regards,
Peter StoevjQWidgets Team
http://www.jqwidgets.comHi Peter,
Thanks for your reply.
I know the ‘checkItem’ method, but I can only do the check action one by one item. what I really want is doing the check action by passing the “source” param (it’s an array object and it contains the checkstate for every items) once.var source = [
{ label: “Item 1”, expanded: true, items: [
{ label: “Item 1.1”, checked: true },
{ label: “Item 1.2”, selected: true}
]
}]if I use $(‘#jqxTree’).jqxTree({ theme: theme, source: source, height: ‘300px’, width: ‘300px’ });
“Item 1.1” in the builed tree will be checked. Is there any solutions?Hi Pei Hu,
It is possible to check items through the API by using the ‘checkItem’ method. The code that you are trying to use, with a ‘checked’ property is not currently supported. This is something that we will consider implementing in the next version.
Best Regards,
Peter StoevjQWidgets Team
http://www.jqwidgets.comHi Peter,
Thank you again!
I am looking forward your next version 😀 -
AuthorPosts
You must be logged in to reply to this topic.