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

How to invoke a controller method on Node click

I am trying to use treeview for redirection to different action based on the action assigned. I tried to use navigateUrl property but it is not working. Sample is attached. I couldn't find a sample in documentation also for this.

Attachment: RemoteData_d32dae7b.zip

3 Replies

MT Muhammad Tassadaque Zia May 9, 2019 07:20 PM UTC

Is more clarity required to get the answer or I am missing something

CI Christopher Issac Sunder K Syncfusion Team May 10, 2019 06:32 AM UTC

Hi Muhammad, 

Greetings from Syncfusion support. 

In the attached sample, you have declared the navigateURL directly inside the fields tag. So that it is not working properly. We have to define the navigateURL individually for each node (like id, parentID defined for each node). Please find the code snippet. 

// Controller part 
public string nodeURL { get; set; } 
TreeData.Add(new ParentNodeViewModel { nodeId = "01", nodeText= "Local Disk (C:)", expanded= true, hasChild= true, nodeURL="/Home/About" }); 
TreeData.Add(new ParentNodeViewModel { nodeId = "01-01", nodeText = "Program Files", hasChild = true, pid = "01", nodeURL= "https://ej2.syncfusion.com/demos/#/material/treeview/check-box.html" }); 

//view part 
<ejs-treeview id="tree"> 
    <e-treeview-fields navigateUrl="nodeURL" id="nodeId" parentId="pid" text="nodeText" hasChildren="hasChild" expanded="expanded"> 
        <e-data-manager url="/Treeview/GetAllData" adaptor="ODataV4Adaptor" crossDomain="true" offline="true"></e-data-manager> 

Please check the above sample and get back to us if you need any further assistance. 


MT Muhammad Tassadaque Zia May 13, 2019 05:00 AM UTC

Thanks It solved my issue

Live Chat Icon For mobile
Up arrow icon