We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date
close icon

Treeview loading slowly

Hello,

I have a TreeView that loads very slowly taking about 5 seconds, attatched is a image of what the treeview looks like with around 350 nodes(The most nodes we ever would have is around 900), the code looks like this:

<ej:treeview
                                    ID="TreeViewPracticeTests"
                                    runat="server"
                                    DataTextField="Text"
                                    DataIdField="ID"
                                    DataParentIdField="ParentID"
                                    ClientSideOnNodeChecked="onCheckProdNode"
                                    ClientSideOnNodeUnchecked="onUnCheckedProdNode"
                                    ClientSideOnCreated="onCreate"
                                    DataHasChildField="HasChild"
                                    DataExpandedField="Expanded"
                                    ChildrenAsTriggers="False"
                                    ShowCheckbox="True" DataIsCheckedField="NodeChecked">
                                </ej:treeview>

                        <asp:HiddenField ID="PracticeTestTreeViewCheckedList" runat="server"/>

OnNodeChecked and OnNodeUnchecked I just get a list of the ids and save them to the hiddenfield, so I have access to them on the code behind.
Those javascript methods look like this:

function onCheckProdNode(args) {
            var lstChecked = args.currentCheckedNodes;
            var arr = [];
            for (var i = 0; i < lstChecked.length; i++) {
                if (lstChecked[i].id > 0) {
                    arr.push(lstChecked[i].id);
                }
            };
           
            var valuefromHiddenField = document.getElementById('<%=PracticeTestTreeViewCheckedList.ClientID%>').value;
            if (valuefromHiddenField == "nothing") {
                document.getElementById('<%=PracticeTestTreeViewCheckedList.ClientID%>').value = arr.toString();
            } else {
                var arrOldItems = document.getElementById('<%=PracticeTestTreeViewCheckedList.ClientID%>').value.split(',');
                var newArr =  arr.concat(arrOldItems);
                document.getElementById('<%=PracticeTestTreeViewCheckedList.ClientID%>').value = newArr.toString();
            }
        }

I have tried to use loadOnDemand but that doesn't seem to work because if a parent node is selected it doesn't have the ids of the child nodes that were selected, because it is not expanded yet.

I previously had this in a asp treeview and there were no speed issues. I don't know if there is something else I can do to make the performance better?

Thanks

Attachment: TreeViewImage_81a03826.zip

1 Reply

AB Ashokkumar Balasubramanian Syncfusion Team March 31, 2017 12:06 PM UTC

Hi Gideon,              
 
The performance of the TreeView issue occurs due to the number of nodes with checked state, it takes time to render those nodes with checkbox and processing actions such as “parent node should be checked based on child nodes checked state, and child nodes checked state based on parent checked state”.  
 
However, we have logged “Need to improve the performance of TreeView control with checkbox enabled” as a feature request in our database to optimize the checkbox functionality for improving performance. We will implement this feature in any of our upcoming releases.  
 
Regards, 
Ashokkumar B.   


Loader.
Live Chat Icon For mobile
Up arrow icon