BoldDeskWe are launching BoldDesk on Product Hunt soon. Learn more & follow us.
Hi
Georg,
Thank you for using Syncfusion products.
To create a treeview with loadondemand, prepare datasource model
with Id,ParentId and text field. The Child node should have Id of the
corresponding parent node in ParentId field. Please refer the following code
snippet,
<code>
[View]
@{Html.Syncfusion().TreeView("MyTreeView").DragandDrop(true).LoadOnDemand(true).RequestMapper("GetPostData")
.ShowLines(true).ShowCheckbox(true).DataSource(Model)
.Width(300).Height(460)
.BindTo(bind =>
bind.Id("Code").ParentId("PCode").Text("Name").Children("PCode")).Render();}
[Controller]
public ActionResult
Index()
{
var data = new FirstLevelList().ListTot;
return View(data);
}
[AcceptVerbs(HttpVerbs.Post)]
public ActionResult
GetPostData(TreeViewModel treeViewModel, BaseItem b)
{
var nodes = new
FirstLevelList().ListTot;
var subNodes = nodes.Where(c => c.PCode == Convert.ToInt32(b.Value));
return new
JsonResult { Data = subNodes };
}
</code>
Please download the sample from the following
link:
Kindly let us know if you have further queries.
Regards,
Ezhil S
Hi Georg,
Thanks for the update.
On using LoadOnDemand in TreeView only the root nodes are loaded
initially in the web page. The child nodes are loaded only on expanding the
root node. Please refer the attached video file in the HTML you can see that
root nodes are loaded initially and child nodes are loaded only after expanding
the node.
Kindly let us know if you require further assistance on this.
Regards,
Ezhil S