knockout-kendo.treeview.js
- Last UpdatedMar 12, 2021
- 1 minute read
// Knockout binding for Kendo Tree View
(function ()
{
var createBinding = ko.kendo.bindingFactory.createBinding.bind(ko.kendo.bindingFactory);
//use constants to ensure consistency and to help reduce minified file size
var ENABLE = "enable"
VALUE = "value";
// Knockout Kendo Tree View
createBinding({
name: "kendoTreeView",
watch: {
data: function (value, options)
{
ko.kendo.setDataSource(this, value, options);
}
},
events: {
change: function (options, e)
{
if (ko.isWriteableObservable(options.value))
{
var tree = e.sender;
options.value(tree.dataItem(tree.select()));
}
}
},
async: true
});
}());