0
votes

I am using RPNiemeyer`s kendo-knockout library, and trying to use a databinding inside a template in kendoGrid. Previously this question had the solution with refreshing bindings, but after I updated to knockout.js 2.3.0, this solution no longer works. knockout.js is now throwing an exception when executing ko.applyBindings multiple times for the same element.

I've also tried implementing it with knockout templates and useKOTemplates, but then sorting the grid by clicking column headers no longer works.

Any ideas how to solve this, or do I have do use kendo MVVM for this?

1

1 Answers

0
votes

For this particular scenario you should be able to add a ko.cleanNode call in the dataBound callback. Something like:

ko.bindingHandlers.kendoGrid.options.dataBound = function(data) {
    var body = this.element.find("tbody")[0];

    if (body) {
       ko.cleanNode(body);
       ko.applyBindings(ko.dataFor(body), body);   
    }
};