Javascript Kendo UI TreeView dataTextField和model.fields.text.from之间的差异
我有一个示例,其中节点的文本由Javascript Kendo UI TreeView dataTextField和model.fields.text.from之间的差异,javascript,model,kendo-ui,kendo-treeview,Javascript,Model,Kendo Ui,Kendo Treeview,我有一个示例,其中节点的文本由title字段提供。TreeView希望该字段为文本。有两种方法可以制作该映射: 将:“title”传递给treeview构造函数 传递schema.model:,它“指定原始记录的字段,该字段的值用于填充模型字段。”即schema:{model:{fields:{text:{from:'title'},…} 在options.fields的文档中,我应该选择哪种方法?使用dataTextField选项可以通过数据中的原始名称引用节点的属性,在本例中为title:
title
字段提供。TreeView希望该字段为文本
。有两种方法可以制作该映射:
:“title”
传递给treeview
构造函数schema.model:
,它“指定原始记录的字段,该字段的值用于填充模型字段。”即schema:{model:{fields:{text:{from:'title'},…}
在
options.fields
的文档中,我应该选择哪种方法?使用dataTextField
选项可以通过数据中的原始名称引用节点的属性,在本例中为title
:
var myHDS = new kendo.data.HierarchicalDataSource({
transport: {
read: function (options) {
var node = myHDS.get(options.data.id);
// node.title is accessible here
}
},
schema: {
model: {
id: 'id',
hasChildren: 'children'
}
}
});
$("#tree-container").kendoTreeView({
dataSource: myHDS,
dataTextField: 'title'
})
将schema.model.fields.text.from
设置为title
需要将节点的title
属性引用为node.text
:
var myHDS = new kendo.data.HierarchicalDataSource({
transport: {
read: function (options) {
var node = myHDS.get(options.data.id);
// node.title is accessible here
}
},
schema: {
model: {
fields: {
text: {
from: 'title'
}
},
id: 'id',
hasChildren: 'children'
}
}
});
$("#tree-container").kendoTreeView({
dataSource: myHDS
})