Kendo UI TreeView dataTextField 和 model.fields.text.from 之间的
Kendo UI TreeView difference between dataTextField and model.fields.text.from
我有一个分层数据源,其中节点的文本由title
字段提供。树视图希望该字段text
。有两种方法可以进行该映射:
- 将
dataTextField
: 'title'
传递给treeview
构造函数 - 传递
schema.model:
fields.text.from
,其中"指定原始记录的字段,该值用于模型字段的填充",即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
})
相关文章:
- 如何将输入(type=text)从html表单传递到javascript函数
- 可以<脚本类型=“;text/javascript”>window.location=“/"</
- 在文本区域中使用jQuery.text()保持换行符
- 用Javascript添加带有#text的tr元素
- 当用户按下回车键时,自动在text区域/text中插入消息
- 修正案'text'的元素
- 图像可以从源<img src=""/>.TEXT可以在没有javascript的情况下从外部
- W3验证器->使用<脚本类型=“;text/javascript”>在html的正文中
- Validate JSON from Mongo?
- Get JSON from an url
- 我如何在INPUT TEXT中使用这个Javascript和jQuery
- <text区域>在我的html中包含event.keycode==13之后,wrap就不起作用了
- 从所有下拉菜单中选择val和text
- creating objects from variables ES6
- getDocument by id/get input text from button dons'不起作用
- Kendo UI TreeView dataTextField 和 model.fields.text.from 之间的
- Remove empty lines when copy text from <p>
- JQuery addition from .text()
- Replace text from <option> to <input>
- remove a specific text from <td> element