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. (Last updated on: June 24, 2019).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

TreeView enable CheckBoxs only in child nodes

Thread ID:

Created:

Updated:

Platform:

Replies:

143032 Mar 1,2019 06:55 AM UTC Mar 4,2019 12:24 PM UTC Angular - EJ 2 1
loading
Tags: Treeview
Neo
Asked On March 4, 2019 03:55 AM UTC

Hi all,

I'm using 'ejs-treeview' component to load parent & child data. Designer code as below,

[animation]='animation' (nodeChecked)='nodeChecked($event)' [showCheckBox]='showCheckBox'>


According to the above code, it will generate TreeView including CheckBoxes with parent node CheckBoxes. My requirement is, CheckBoxes should be
load only in Child nodes. Sample control designer as below. (Note: This sample made by designing tool)


My second requirement is, when we checking on the 'N2 Child 4' node, all other parent child nodes should be unchecked & when we checking on any other
child node that 'N2 Child 4' node should be unchecked. These requirements are highly important to me and highly appreciate if can be achieved.

Thank you


Christopher Issac Sunder K [Syncfusion]
Replied On March 4, 2019 12:24 PM UTC

Hi Shamil, 

Thank you for contacting Syncfusion support. 

We have analyzed your requirements and prepared a sample based on that. 
 
Query-1: Checkboxes should be enabled only in child nodes 
For this case, you can disable the check box for the parent node in the created event of treeview. Please find the code snippet 

let liEle = this.treevalidate.element.querySelectorAll('li'); 
for (let i = 0; i < liEle.length; i++) { 
    if (liEle[i].classList.contains('e-level-1')) { 
        let element = liEle[i].querySelector('.e-checkbox-wrapper'); 
        if (element) 
            element.parentElement.removeChild(element); 
    } 
    this.treevalidate.checkAll(); 
    this.treevalidate.uncheckAll(['11']); 
} 
 
Query-2: Checking the last child node 'N2 Child 4' should uncheck all other parent child nodes . 
You can achieve this in the nodeChecking event of treeview. 

We have prepared the sample by considering the 'N2 Child 4' node. Please check the sample and let us know whether it fulfills your requirement. 

Please let us know if you require any further assistance. 

Thanks, 
Christo

CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Please sign in to access our forum

This page will automatically be redirected to the sign-in page in 10 seconds.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

Live Chat Icon For mobile
Live Chat Icon