I have an MVC Treeview identical to the Treeview Binding Remote Data code sample as well as the one if the video Kendo UI for ASP.NET MVC TreeView but I cannot seem to get the Id to be passed to my controller when the tree is expanded.
The examples show the id being passed in the querystring.
@(Html.Kendo().TreeView() .Name("my-Tree-View") .DataTextField("Name") .DataSource(dataSource => dataSource .Read(read => read .Action("GetSourcesByID", "source") )) )My initial results look like this and my Tree appears to be properly displayed:
[{"Id":"AK","Name":"AK","hasChildren":true},{"Id":"AL","Name":"AL","hasChildren":true},{"Id":"AR","Name":"AR","hasChildren":true},...]In case it matters here is my controller:
public ActionResult getSourcesByID(string id) { IList<TreeViewModel> sourceVM = new List<TreeViewModel>();
if (id == null) { var QueryStates = from source in context.states select new { state = source.state1 , }; foreach (var prod in QueryStates) { sourceVM.Add(new TreeViewModel { Id = prod.state, Name=prod.state, hasChildren=true }); } } else { var Query = from source in context.sources where source.state == id select new { sourceid = source.sourceid, state = source.state, sourcename = source.sourcename }; foreach (var prod in Query) { sourceVM.Add(new TreeViewModel { Id = prod.sourceid.ToString() , Name = prod.sourcename, hasChildren=false }); } } return Json(sourceVM, JsonRequestBehavior.AllowGet); }What else do I need to do to force it to send the ID?
Brad