I have a Kendo tree that I am binding using local data
Everything works fine with the code I have.
However, I am trying to add custom attributes to the items generated, like data-name
.
How can I do this using kendo.data.HierarchicalDataSource
?
// bind kendo tree
var treeDataSource = new kendo.data.HierarchicalDataSource({
data: [{ Id: "id", Text: "Node 1", HasChildren: false, ChildrenFolders: [], HtmlAttributes: { "data-name": "Custom Name" } }],
schema: {
model: {
children: "ChildrenFolders",
hasChildren: "HasChildren",
id: "Id",
htmlAttributes: "HtmlAttributes"
}
}
});
this.kendoTreeView = $("#tree").kendoTreeView({
dataSource: treeDataSource,
dataTextField: "Text",
loadOnDemand: false
}).data("kendoTreeView");