This is a migrated thread and some comments may be shown as answers.

Grid with datasource bound to Wcf, after Update, null ref in Kendo.web.js

1 Answer 197 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Mike
Top achievements
Rank 1
Mike asked on 28 Mar 2012, 08:52 PM
I have a Kendo Grid bound to a Wcf service that follows the example found in https://github.com/telerik/kendo-examples-asp-net/tree/master/grid-wcf-crud 

This sample is based on a Wcf using <enableWebScript />.  My service's Update receives the DTO from Kendo Datasource and updates perfectly, returning {"d":null}, exactly as does the grid-wcf-crud project's Product.cs Update service method.

Back in the browser, the in IE9, an error is experienced in kendo.web.js:
  Line: 5128
  Error: Unable to get value of the property 'length': object is null or undefined

it is likely happening in the code that is seeking to mark the rows as not dirty, because they are included in the next Save invocation, and are still marked with a red tic mark.

This error does not happen in Chrome.  This error does not happen in IE  when running the grid-wcf-crud.  I cannot find any difference between my implementation and the sample.  web.config is virtually the same between my app having the error compared to the grid-wcf-crud sample that does not have the error.  Any ideas?

The code in kendo.web.js that is hitting the error follows, with the error on the last line where data is null in " length = data.length ":

    var DataReader = Class.extend({
        init: function(schema) {
            var that = this, member, get, model;
            schema = schema || {};
            for (member in schema) {
                get = schema[member];
                that[member] = typeof get === STRING ? getter(get) : get;
            }
            if (isPlainObject(that.model)) {
                that.model = model = kendo.data.Model.define(that.model);
                var dataFunction = that.data,
                getters = {};
                if (model.fields) {
                    each(model.fields, function(field, value) {
                        if (isPlainObject(value) && value.field) {
                            getters[value.field] = getter(value.field);
                        } else {
                            getters[field] = getter(field);
                        }
                    });
                }
                that.data = function(data) {
                    var record,
                        getter,
                        idx,
                        length,
                        modelInstance = new that.model();
                    data = dataFunction(data);
                    if (!isEmptyObject(getters)) {
                        for (idx = 0, length = data.length; ...........

1 Answer, 1 is accepted

Sort by
0
Daniel
Telerik team
answered on 30 Mar 2012, 10:19 AM
Hello Mike,

Thank you for bringing this problem to our attention. It occurs in the latest version when returning null as result. We will fix this for the next official release. A quick workaround for now is to handle the schema data function and return an empty array when the data is null. For example:
schema: {
   data: function (data) {
       return data.d || [];
   }



All the best,
Daniel
the Telerik team
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
Tags
Grid
Asked by
Mike
Top achievements
Rank 1
Answers by
Daniel
Telerik team
Share this question
or