我这里有一个已经加载好的静态二级kendotreeview树控件,现在需要在第二级节点下通过传入第一级节点和地二级节点数据作为参数查询第三级节点的数据并加载在第二级节点下作为第三级节点。
如果是数据查询是二维表格只需要 parentId即可,取到集合后foreach创建 三级节点即可。
能举的例子么?
//加载参数树
this.onLoadTreeData = function () {
var Products = {
dataType: "json",
type: "GET",
schema: {
data: function (result) {
var finalData = GetObjByJsonString(result);
return finalData.result || finalData;
},
model: {
id: "kpi_str",
spriteCssClass: "html",
hasChildren: function () {
return false;
}
}
},
transport: {
read: {
url: function (options) {
return kendo.format("/ParameterAudit/GetParameterLinkageForCA?plugin=ParameterAuditFlowPlugin&intId=" + $("#hidNeId").val(), options.str_type + "&t=" + new Date());
//return kendo.format("/ParameterAudit/JXGetParameterLinkageForCA?plugin=ParameterAuditFlowPlugin&intId=" + options.LEVELTYPE, options.str_type + "&t=" + new Date());
}
}
}
};
//var Levels = {
// dataType: "json",
// type: "GET",
// schema: {
// data: function (result) {
// var finalData = GetObjByJsonString(result);
// return finalData.result || finalData;
// },
// model: {
// id: "LEVELTYPE",
// spriteCssClass: "folder",
// children: Products
// }
// },
// transport: {
// read: {
// url: function (options) {
// return kendo.format("/ParameterAudit/JXGetParameterLinkageForLevel?plugin=ParameterAuditFlowPlugin&intId=" + options.str_type + "&t=" + new Date());
// }
// }
// }
//};
Categories = new kendo.data.HierarchicalDataSource({
//data: [{
// str_type: "8",
// CategoryName: "华为",
// hasChildren: true,
// spriteCssClass: "folder"
//}, {
// str_type: "7",
// CategoryName: "中兴",
// hasChildren: true,
// spriteCssClass: "folder"
//}, {
// str_type: "4",
// CategoryName: "诺基亚",
// hasChildren: true,
// spriteCssClass: "folder"
//}],
//schema: {
// model: {
// id: "str_type",
// children: Levels
// }
//}
data: [{
str_type: "A",
CategoryName: "A 类 参 数",
hasChildren: true,
spriteCssClass: "folder"
}, {
str_type: "B",
CategoryName: "B 类 参 数",
hasChildren: true,
spriteCssClass: "folder"
}, {
str_type: "C",
CategoryName: "C 类 参 数",
hasChildren: true,
spriteCssClass: "folder"
}],
schema: {
model: {
id: "str_type",
children: Products
}
}
});
var treeview = $("#treeview").data("kendoTreeView");
if (treeview) {
treeview.setDataSource(Categories);
$("#treeview").data("kendoTreeView").dataSource.bind("change",
function () {
_this.refreshGridData();
}
);
} else {
$("#treeview").kendoTreeView({
checkboxes: {
checkChildren: true
},
loadOnDemand: true,
Expanded: true,
dataSource: Categories,
dataTextField: ["CategoryName", "PARA"] //VENDOR_PARANAME
//dataTextField: ["CategoryName","level_str", "FIELDNAME"] //VENDOR_PARANAME
});
$("#treeview").data("kendoTreeView").dataSource.bind("change",
function () {
_this.refreshGridData();
}
);
}
return;
};