Reputation: 11731
I have a kendo tree which i am trying to bind it to a local json arrray.
Trying to map my json object properties to what treeView expects is not working.
The value of the "text" property is the function definition (function (item){ return item.Text; }
) The function itself doesn't gets evaluated
Html:
<div id="tree"></div>
Javascript:
var data = [
{
"Text": "Some dummy text"
}
];
var inlineDefault = new kendo.data.HierarchicalDataSource({
data: data,
schema: {
model: {
text: function(item){
return item.Text;
}
}
}
});
$("#tree").kendoTreeView({
dataSource: inlineDefault
});
Upvotes: 0
Views: 2297
Reputation: 11967
Instead of using projection in the data source, use the TreeView dataTextField to define where your data is located:
var data = [
{
"Text": "Some dummy text"
}
];
var inlineDefault = new kendo.data.HierarchicalDataSource({
data: data
});
$("#tree").kendoTreeView({
dataTextField: "Text",
dataSource: inlineDefault
});
Upvotes: 1
Reputation: 18402
Defining a schema model in this way is not supported - see the options here,the additional field for hierarchical data sources here and an example on how to create a tree view here.
Upvotes: 0