- Home
- Forum
- ASP.NET MVC
- Two way data binding for TreeView
Two way data binding for TreeView
I have checked the actual HTTP headers and the POST does include the selected node information but the model is not being updated. All of the examples I can find are only for displaying data, not receiving data back.
|
[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(); } |
- 1 Reply
- 2 Participants
-
JB Jonathan Byrne
- Nov 10, 2015 09:45 PM UTC
- Nov 11, 2015 07:37 PM UTC