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

Unexpanded tree element doesn't get checked

Hello,

I'm using TreeView with checkboxes and on initial rendering I'm getting ID's from database and by those ID's I'm checking treeView items. But I found an issue, the tree node won't be marked as checked if it's not expanded before selectedNodes or .checkAll() apply.

Query: How to programmatically mark node as checked even if it is not expanded. 

I've reproduces issue in one of your demos:

3 Replies

CI Christopher Issac Sunder K Syncfusion Team February 14, 2019 10:27 AM UTC

Hi Domantas, 

Thank you for contacting Syncfusion support. 

You can overcome the reported issue by setting 'loadOnDemand' property as false. We have prepare a sample for your reference.

 

For more information please refer the following documentation link 

We have also provided the option to check the non-expanded child node while enabling the loadOnDemand. This support will be available in our upcoming volume 1, 2019 release which is expected to be rolled out in the month of March, 2019. 

Please let us know if you require any further assistance. 

Thanks, 
Christo 



DO Domantas February 15, 2019 07:54 AM UTC

Hello,

Thank you for your answer, it solved the issue.

I got one more question with TreeView. I do change autoCheck while being in action. And the problem is that if selected parent has no selected childs it will get unchecked.

Query 1: How do I maintain same selectedNodes before autoCheck and after autoCheck. For example if I still want parent to maintain selected and be in selectedNodes even if it has no selected child

Query 2: Can I somehow get rid of "mixed" status and leave just checked and unchecked


In example we got 2 parents selected, one parent has selected child another one doesn't.


This is what happens when I apply this.treeView.autoCheck = true. Parent that had selected child gets "mixed" status, but the one that didn't selected child gets unselected. And now selectedNodes before autoCheck and after autoCheck are different, but I only changed the property.



PO Prince Oliver Syncfusion Team February 18, 2019 12:08 PM UTC

Hi Domantas, 

Thank you for your update. 

While enabling autoCheck option, the parent node will be in the checked state, only if all the child Nodes are checked. Otherwise it will be in mixed state, even if any one of its child items are not checked. This is the default behavior of TreeView when the autoCheck property is enabled. 

If you still want to maintain the parentNode in checked state, you need to push the parentNode into the checked node before enabling the autoCheck property. But this will select all the child nodes of specific parent node. 


Please check the above sample and let us know whether you need to achieve this behavior. Please let us know if you need any further assistance on this. 

Regards, 
Prince 


Loader.
Live Chat Icon For mobile
Up arrow icon