Hi,
Can anyone help me on how to solve this issue? I was able to see the parent nodes but not the children.
Json result:
[{"PartNo":"1KK-21BD","HasChild":true,"_items":[{"ChildPartNo":"9003"},{"ChildPartNo":"7043"},{"ChildPartNo":"4036"},{"ChildPartNo":"9023"},{"ChildPartNo":"9040"}]}]
Below is my code:
@(Html.Kendo().TreeView()
.Name("treeview")
.HtmlAttributes(new {@class="demo-section" })
.LoadOnDemand(false)
.DataTextField("PartNo")
.DataSource(dataSource => dataSource
.Read(read => read
.Action("Search", "Home").Data("GetInfo")
)
)
)
function btnSearch_click() {
GetInfo();
}
function GetInfo() {
$.ajax({
type: "POST",
dataType: "json",
contentType: 'application/json; charset=utf-8',
data: JSON.stringify({
PartNo: $('#txtNo').val()
}),
url: "@Url.Action("Search", "Home")",
success: function (result) {
debugger;
var dataSource = new kendo.data.HierarchicalDataSource({
data: result,
schema: {
model: {
PartNo: 'PartNo',
children: '_items',
hasChildren: 'HasChild'
}
}
});
$("#treeview").data("kendoTreeView").dataSource.data(dataSource.options.data);
}
})
Thanks for your help!!
Can anyone help me on how to solve this issue? I was able to see the parent nodes but not the children.
Json result:
[{"PartNo":"1KK-21BD","HasChild":true,"_items":[{"ChildPartNo":"9003"},{"ChildPartNo":"7043"},{"ChildPartNo":"4036"},{"ChildPartNo":"9023"},{"ChildPartNo":"9040"}]}]
Below is my code:
@(Html.Kendo().TreeView()
.Name("treeview")
.HtmlAttributes(new {@class="demo-section" })
.LoadOnDemand(false)
.DataTextField("PartNo")
.DataSource(dataSource => dataSource
.Read(read => read
.Action("Search", "Home").Data("GetInfo")
)
)
)
function btnSearch_click() {
GetInfo();
}
function GetInfo() {
$.ajax({
type: "POST",
dataType: "json",
contentType: 'application/json; charset=utf-8',
data: JSON.stringify({
PartNo: $('#txtNo').val()
}),
url: "@Url.Action("Search", "Home")",
success: function (result) {
debugger;
var dataSource = new kendo.data.HierarchicalDataSource({
data: result,
schema: {
model: {
PartNo: 'PartNo',
children: '_items',
hasChildren: 'HasChild'
}
}
});
$("#treeview").data("kendoTreeView").dataSource.data(dataSource.options.data);
}
})
Thanks for your help!!