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

Search in treeview/Remove selection for parent items

Hello,

I am using the treeview control. It works fine but need to have some functionalities which i'm unable to find. I want to be able to search treeview. Is there any way by which i can achieve the same? Now a days, it's very common i think.

Apart from that, it would be nice if i can find a way by which i can only select(checkboxes) leaf nodes. In other words,any parent can't be selected.

Request you to provide any insights regarding the same.

1 Reply

AB Ashokkumar Balasubramanian Syncfusion Team May 24, 2017 10:11 AM UTC

Hi Kuntal, 
 
Query 1: How to search the tree nodes in TreeView. 
 
Currently in our TreeView component, there is no inbuilt support to search the Tree nodes in TreeView control. We have logged this as a new feature request in our database. We will implement this feature in any of our future releases.  
But we can achieve your requirement in application level, please check the details in below help document. 
 
 
For your reference, we have prepared simple playground sample for your requirement, please check the sample in below JS Playground. 
 
 
Query 2: I can only select(checkboxes) leaf nodes, parent can't be selected. 
 
We have analyzed requirement. We could see that you have achieved this requirement using TreeView component “AutoCheck” property and “NodeCheck” event. Please refer the below code snippet. 
 
[CSHTML] 
 
@Html.EJ().TreeView("tree").Items(items => 
                { 
                    items.Add().Text("File").Children(child => 
                    { 
                        child.Add().Text("New"); 
                        child.Add().Text("Open"); 
                        child.Add().Text("Save"); 
                        child.Add().Text("Save As"); 
                        child.Add().Text("Print Preview"); 
                        child.Add().Text("Print"); 
                        child.Add().Text("Close"); 
                    });             }).ShowCheckbox(true).AutoCheck(false).ClientSideEvents(evt=>evt.NodeCheck("onNodeCheck")) 
 
[Script] 
function onNodeCheck(args) { 
     if (args.currentElement[0].childElementCount != 1) 
          this.uncheckNode(args.currentElement) 
} 
 
 For your reference, we have prepared simple sample, it can be downloaded in below location. 
 
 
Please let us know, if the provided sample is helpful for your requirement or not. 
 
Regards, 
Ashokkumar B. 


Loader.
Up arrow icon