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

Don't checkchildren on datasource load

1 Answer 101 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
I. Breukink
Top achievements
Rank 1
I. Breukink asked on 26 Aug 2013, 09:49 AM
I have a treeview with subitems. I want to have the ‘checkchildren’ optie set to true, so if a user click on a parent, als the children are checked.
But I also want to be able to uncheck some childeren, while parent remains checked.

The problem is when i load the treeview, and i have the above situation (a parent checked and only a few of the subitems), all the subitems are then automatically checked. At that point the treeview is not representing the checked items anymore that were supplied in the datasource. 

So how can i achieve that (1)on a form submit, the parent is also marked as ‘checked’ when not al subitems are checked and (2)prevent that on a load with a datasource, all the childeren are automatically checked if a parent is checked and (3) that on a select of a parent with a mouseclick, all subitems are checked.


Thanks

1 Answer, 1 is accepted

Sort by
0
Alex Gyoshev
Telerik team
answered on 28 Aug 2013, 03:08 PM
Hello Ivor,

For item #1, iterate through the tree checkboxes and reset their indeterminate state:
$("#treeview :checkbox").each(function() {
    if (this.indeterminate) {
        this.checked = true;
    }
});

I am afraid that item #2 is not supported. If the parent node is serialized as "checked" and the child nodes have conflicting data, their state is reset by the parent. The issue here is that the treeview knows whether the item has been checked only from the data that is in the datasource.

I could not really understand item #3. Isn't this conflicting with #2? Or do you mean on the server?

Regards,
Alex Gyoshev
Telerik
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
Tags
TreeView
Asked by
I. Breukink
Top achievements
Rank 1
Answers by
Alex Gyoshev
Telerik team
Share this question
or