gpt4 book ai didi

javascript - Kendo UI 层次结构子架构

转载 作者:行者123 更新时间:2023-12-03 22:52:17 24 4
gpt4 key购买 nike

关于 Kendo 的 API 引用(证明: Kendo UI API Reference - Schema.Model.Children ),可以在下一个方法中声明子节点(参见嵌套的“模式”作为“定义第二级选项”):

var datasource = new kendo.data.HierarchicalDataSource({
data: [
{
categoryName: "SciFi",
movies: [
{ title: "Star Wars: A New Hope", year: 1977, cast: [
{ actor: "Mark Hamill", character: "Luke Skywalker" },
{ actor: "Harrison Ford", character: "Han Solo" },
{ actor: "Carrie Fisher", character: "Princess Leia Organa" }
] },
{ title: "Star Wars: The Empire Strikes Back", year: 1980, cast: [
{ actor: "Mark Hamill", character: "Luke Skywalker" },
{ actor: "Harrison Ford", character: "Han Solo" },
{ actor: "Carrie Fisher", character: "Princess Leia Organa" },
{ actor: "Billy Dee Williams", character: "Lando Calrissian" }
] }
]
}
],
schema: {
model: {
children: { // define options for second level
schema: {
data: "movies",
model: {
children: "cast" // third level is defined by the field "cast"
}
}
}
}
}
});

我对 HierarchicalDataSource 使用类似的定义并以这种方式获取子节点:
schema: {
model: {
id: "urb_fltr",
hasChildren: true,
children: "PhoneCalls" // <- here is definition for children that are - data from field of output (next in parse)
},
parse: function (data) {
var outRes = [];
var dataRes = [];
var tmpLoop = 0;
var bordNum = 251170009;

if (data.d.results != null && data.d.results.length > 0)
for (var step = 0; step < data.d.results.length; step++) {

if (data.d.results[step] == null) continue;

var stepData = data.d.results[step];

var stepValue = (stepData.urb_subject != null) ? stepData.urb_subject.Value : 0;

var arrValue = (stepValue > bordNum) ? stepValue - bordNum : 0;

if (outRes[arrValue] == null || typeof (outRes[arrValue]) == 'undefined') {
outRes[arrValue] = {};
outRes[arrValue].urb_total = 1;
outRes[arrValue].urb_clnts = 0;

outRes[arrValue].OwnerId = stepData.OwnerId;
outRes[arrValue].urb_subjectValue = stepValue;

outRes[arrValue].PhoneCalls = []; // <- children
}
else
outRes[arrValue].urb_total += 1;
// fill children field
outRes[arrValue].PhoneCalls[outRes[arrValue].urb_total - 1] = {};
outRes[arrValue].PhoneCalls[outRes[arrValue].urb_total - 1].CallId = stepData.ActivityId;
outRes[arrValue].PhoneCalls[outRes[arrValue].urb_total - 1].urb_name = stepData.urb_name;
outRes[arrValue].PhoneCalls[outRes[arrValue].urb_total - 1].CreatedOn = stepData.CreatedOn;
outRes[arrValue].PhoneCalls[outRes[arrValue].urb_total - 1].PhoneNumber = stepData.PhoneNumber;
outRes[arrValue].PhoneCalls[outRes[arrValue].urb_total - 1].ScheduledEnd = stepData.ScheduledEnd;

if (stepData.RegardingObjectId != null && stepData.RegardingObjectId.Id != null && stepData.RegardingObjectId.LogicalName == "lead") {
outRes[arrValue].PhoneCalls[outRes[arrValue].urb_total - 1].RegardingObjectId = stepData.RegardingObjectId;
outRes[arrValue].urb_clnts += 1;
}
}

for (var loop = 0; loop < outRes.length; loop++)
if (typeof (outRes[loop]) != 'undefined') {
outRes[loop].urb_subjectName = outRes[loop].urb_subjectName + " ( " + outRes[loop].urb_total + " - " + outRes[loop].urb_clnts + " )";
dataRes[tmpLoop] = outRes[loop];
tmpLoop++;
}

return dataRes; //data.d.results;
},
type: "json"
}

没关系。我可以这样看待 child 。但默认情况下,'hasChildren' 的属性为 'true',我为子节点添加了方案,如 API 引用:
children: { // <- instead of "PhoneCalls" - next 'schema'
schema: {
data: "PhoneCalls",
model: { hasChildren: false }
}
}

,而且相当失去 child 。

任何人都可以帮助正确定义带有方案的子属性吗?

最佳答案

你可以只设置treeview的数据,不用定义schema就可以了。

data = [{id: '1', text: 'Music', items: [{id: '1.1', text: 'Country', items: []}, {id: '1.2', text: 'Jazz' , 项目: []}]}];

$("#treeView").data("kendoTreeView").dataSource.data(data);

关于javascript - Kendo UI 层次结构子架构,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33615957/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com