Hi Everyone,
I'm trying to add custom attributes to treeview nodes. I'm querying a web api 2 service trough a $.ajax call. On success event I firstly create an observable containing an observableHierarchy and then I bind it with the kendo tree view.
$.ajax({
url: serviceBaseUrl + "/Arguments/GetCategoryArgumentMap",
success: function(data) {
//Gestione espansione di tutti i nodi
//$(data).each(function() {
// this["expanded"] = true;
//});
var checkedNodesNameClient = [];
argumentsDataSource = kendo.observable({
hItem: kendo.observableHierarchy({
data: data,
schema: {
model: {
children: "Associateds",
id: "ArgumentId",
expanded: true
}
}
})
});
$("#treeview").kendoTreeView({
checkboxes: {
checkChildren: true,
template: function(data) { console.log(data.item.Associateds); return "<input type='checkbox' data-mainArgument='" + data.item.Associateds.mainArgument + "' />"; }
},
dataTextField: "ArgumentCode",
check: onTreeViewItemCheck,
select: onTreeviewItemSelection,
dataSource: argumentsDataSource.hItem,
dataBound : function () {
$("#treeview > ul > li > div span.k-checkbox").hide();
$("#treeview INPUT[type='checkbox']").addClass("km-widget");
}
});
checkTreeViewItems(viewModel.result.AssociatedArguments, $("#treeview").data("kendoTreeView"), checkedNodesNameClient)
$("#argumentsFilter").bind("keyup", function(){
$("#treeview > UL > LI").hide();
$("#treeview > UL > LI:contains('" + $(this).val() + "')").show();
});
$("#selectedTVItems").text(checkedNodesNameClient.join(", "));
}
});
How can I achive my target?