Articles in this section

How to select the Tree Node by passing the ID from the Controller to View?

Description

By using the SelectedNode API, you can select the specified TreeView node in the TreeView control.

Solution

You have to pass the value to the SelectedNode of the TreeView builder in the View page, as shown in the following code example.

 

View

@Html.EJ().TreeView("NewsCate").TreeViewFields(s => s.Datasource((IEnumerable<TreeViewID.Models.loadondemand>)ViewBag.datasource).Id("i_newscate_id").ParentId("i_parent_id").Value("i_newscate_id").Text("u_title").HasChild("hasChild").Expanded("expanded")).LoadOnDemand(true).Width("auto").SelectedNode(ViewBag.data)

The ViewBag.data contains the value from the Controller page, as shown in the following code example.

 

Controller

public ActionResult TreeViewFeatures()
{
     . . . 
     ViewBag.data = 2;
     return View();
}

Thus, the tree node can be selected in the TreeView control.

 

Sample Link:

http://www.syncfusion.com/uploads/user/forum/118797/ze/TreeViewID_(2)-1133243804

Did you find this information helpful?
Yes
No
Help us improve this page
Please provide feedback or comments
Comments (0)
Access denied
Access denied