This is a migrated thread and some comments may be shown as answers.

Getting checked children

2 Answers 149 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
Ole
Top achievements
Rank 1
Ole asked on 25 Apr 2013, 12:43 PM
Hi. 

I am trying to figure out how I get only the checked children of a node, not checked grand children. 

I use this code at the moment, fires when i click on a link attached to the parent:

var tree = $("#treeview").data("kendoTreeView");
var items = $(this).closest(".k-item").find(".k-group .k-item input[type=checkbox]:checked");
                items.each(function() {
                    var getNode = $(this).closest(".k-item");
                    var item = tree.dataItem(getNode);
                    console.log(item.id);
                });
            }

This code gives me all checked children, grand children and so on, but i need only the children. I tried changing the .find() filter with .children() filter, but then items is empty.

Can anyone point me in the right direction? Your help is much much appreciated.

2 Answers, 1 is accepted

Sort by
0
Accepted
Dimiter Madjarov
Telerik team
answered on 25 Apr 2013, 01:44 PM
Hello Ole,


To get only the first level children of the item you could use the jQuery Child Selector. Here is a sample implementation, that could be modified according to your needs or split into several selectors for better readability.

E.g.
$(this).closest(".k-item").find(".k-group:first > .k-item > div input[type=checkbox]:checked");

I hope this information was helpful for you.

 

Regards,
Dimiter Madjarov
the Telerik team
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
Ole
Top achievements
Rank 1
answered on 25 Apr 2013, 01:54 PM
Thank you. That did work as expected.
Tags
TreeView
Asked by
Ole
Top achievements
Rank 1
Answers by
Dimiter Madjarov
Telerik team
Ole
Top achievements
Rank 1
Share this question
or