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

Unchecking/Checking parent when child is checked/unchecked

5 Answers 440 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
Ole
Top achievements
Rank 1
Ole asked on 26 Apr 2013, 12:23 PM
Hi.

I have a treeview which I implemented with checkchildren set to true, but causes IE8 to show a message about a long running script when there is over 100 nodes.

I therefore tried to implement my own functionality using jquery. I managed to check/uncheck children based on parent with the code:

function onTreeDataBound () {
        $("input:checkbox[name=checkedNodes]").on('click', function () {
            var checkedStatus = $(this).is(':checked');
            $(this).closest(".k-item").find(".k-group .k-item input:checkbox[name=checkedNodes]").each(function () {
                    $(this).attr('checked', checkedStatus);
                });
        });
    }
This seems faster then the built in functionality. What i need now is a way to uncheck parents if one child is unchecked and check parents if all children is checked.

Does anyone have a sample code for this? Or a tips on how I can get the built in functionality to work better with IE8?

5 Answers, 1 is accepted

Sort by
0
Alex Gyoshev
Telerik team
answered on 29 Apr 2013, 08:02 AM
Hello Ole,

Consider using the loadOnDemand: true configuration option in order to optimize the tree performance. It will only show the loaded nodes in the DOM, which will make every operation faster (unless the treeview is fully expanded). Here is a jsBin sample that shows this approach.

Please note that re-implementing this functionality in custom code is out of scope of our support package. However, we will make an effort to improve the performance when the default checkbox template is used.

Greetings,
Alex Gyoshev
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 29 Apr 2013, 08:18 AM
I have implemented the tree with loadOnDemand set to true. It works ok when I have two levels, top node with 18 children. But when I have 3 levels (top node, 18 children one of the children have 64 children) it takes several seconds to check/uncheck the nodes when I check/uncheck top node.
0
Alex Gyoshev
Telerik team
answered on 29 Apr 2013, 08:57 AM
Hello Ole,

Is the TreeView fully expanded? If not, please provide a sample that shows the problem, preferably in jsBin. If it is fully expanded, the loadOnDemand option will not help.

Regards,
Alex Gyoshev
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 29 Apr 2013, 09:07 AM
Yes. The tree is fully expanded, so 83 nodes get checked/unchecked.
0
Alex Gyoshev
Telerik team
answered on 29 Apr 2013, 03:18 PM
Hello Ole,

We have significantly improved the performance of the checkChildren functionality through a bugfix that will land in the next internal build (available for customers with a subscription).

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