Hi
Output : Json Data -
I am seeing two nodes name & name123, but when I click on name node I see another set of name and name123 and this keeps goes as I click. Wondering why the tree nodes are getting created for each click on the node arrow. Am I doing something wrong ?
I have the following View, Controller and Scripts as follows.
Index.chtml
Controller
Output : Json Data -
I am seeing two nodes name & name123, but when I click on name node I see another set of name and name123 and this goes on as I keep clicking. Wondering why the tree nodes are getting created for each click on the node arrow. Any idea about this behavior ?
Output : Json Data -
[{"id":1,"name":"name","hasData":true},{"id":2,"name":"name123","hasData":false}]
I am seeing two nodes name & name123, but when I click on name node I see another set of name and name123 and this keeps goes as I click. Wondering why the tree nodes are getting created for each click on the node arrow. Am I doing something wrong ?
I have the following View, Controller and Scripts as follows.
Index.chtml
<link href="@Url.Content("~/Content/Site.css")" rel="stylesheet" type="text/css" /> <link href="@Url.Content("~/Content/kendo/2012.3.1315/kendo.common.min.css")" rel="stylesheet" type="text/css" /> <link href="@Url.Content("~/Content/kendo/2012.3.1315/kendo.dataviz.min.css")" rel="stylesheet" type="text/css" /> <link href="@Url.Content("~/Content/kendo/2012.3.1315/kendo.default.min.css")" rel="stylesheet" type="text/css" /> <link href="@Url.Content("~/Content/kendo/2012.3.1315/kendo.dataviz.default.min.css")" rel="stylesheet" type="text/css" /> <script src="@Url.Content("~/Scripts/kendo/2012.3.1315/jquery.min.js")"></script> <script src="@Url.Content("~/Scripts/kendo/2012.3.1315/kendo.all.min.js")"></script> <script src="@Url.Content("~/Scripts/kendo.modernizr.custom.js")"></script>
</link>
@{ ViewBag.Title = "Data"; } <h2>@ViewBag.Message</h2> <div id="treeview" class="treeview-back"></div>
<script type="text/javascript"> $(document).ready(function () { buildTree(); }); function buildTree() { var homogeneous = new kendo.data.HierarchicalDataSource({ transport: { read: { url: "Home/RData", dataType: "json" } }, schema: { model: { id: "id", hasChildren: "hasData" } } }); $("#treeview").kendoTreeView({ dataSource: homogeneous, dataTextField: ["name"] }); }
Controller
public class HomeController : Controller { public ActionResult Index() { ViewBag.Message = "Data"; return View(); } public ActionResult About() { return View(); } [HttpGet] public JsonResult RData() { List<TModel> sites = new List<TModel>(); TModel tModel = new TModel{id = 1, name = "name", hasData = true}; sites.Add(tModel); tModel = new TModel { id = 2, name = "name123", hasData = false}; sites.Add(tModel); var resources = from e in sites select new TModel() { id = e.id, name = e.name, hasData = e.hasData }; return Json(resources, JsonRequestBehavior.AllowGet); } } public class TModel { public int id; public string name; public bool hasData; }
Output : Json Data -
[{"id":1,"name":"name","hasData":true},{"id":2,"name":"name123","hasData":false}]
I am seeing two nodes name & name123, but when I click on name node I see another set of name and name123 and this goes on as I keep clicking. Wondering why the tree nodes are getting created for each click on the node arrow. Any idea about this behavior ?