kendo-labs / knockout-kendo

A project to create a robust set of Knockout.js bindings for the Kendo UI widgets.
http://kendo-labs.github.com/knockout-kendo/
274 stars 144 forks source link

"Built in" Add Command on Grid breaking when using serverside controls also #76

Open HennieL opened 11 years ago

HennieL commented 11 years ago

Hi,

I am working on a project where some of our views(older) are not using kendo-knockout.js but the file is included in our shared layout. I am loving the kendo-konckout library, but found that it interfered with the natural way that kendo's grid works when using the built in add Commands on the grid. When removing the scripts those views worked, but obviously our views that use kendo-knockout didn't.

I debugged a bit and found that I get a value of null result in the piece of code below. I changed it to check for null and it sorted out my problem. result might come back with null./undefined in some cases which will cause errors. I reckon it could be a good plan to check for that and handle it in some gracious way?

Null/undefined error found on line 298 of script

(function () { var existing = kendo.data.ObservableArray.fn.wrap; kendo.data.ObservableArray.fn.wrap = function (object) { var result = existing.apply(this, arguments); result._raw = function () { return object; } return result; }; })();

I replaced the above code with this and it sorted out my problem... //attach the raw data after Kendo wraps our items (function () { var existing = kendo.data.ObservableArray.fn.wrap; kendo.data.ObservableArray.fn.wrap = function (object) { var result = existing.apply(this, arguments); if (result != undefined) { result._raw = function () { return object; }; } return result; }; })();

chrs Hennie

rniemeyer commented 11 years ago

Yes, that check definitely looks like a good one. Probably will make sure that result exists and is an object.