[VIEW]
@Html.EJ().TreeView("tree").TreeViewFields(s => s.Datasource((IEnumerable<MvcApplication1.Models.loadondemand>)ViewBag.datasource).Id("id").ParentId("pid").Text("name").HasChild("hasChild").Expanded("expanded")).ClientSideEvents(e=>e.NodeSelect("selectNode")) |
<script> function selectNode() { treeObj = $("#tree").data("ejTreeView"); var selectedNode = treeObj.getSelectedNodeIndex(); $.ajax({ url: "/TreeView/getselctednode", type: "post", data: { 'selectednode': selectedNode } }) } </script> |
[Controller]
[HttpPost] public ActionResult getselctednode(string selectednode) { // Give your code to model update for the selected nodes. return View(); } |