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

Bug: Undefined data not handled in DataReader

1 Answer 102 Views
Data Source
This is a migrated thread and some comments may be shown as answers.
Steven
Top achievements
Rank 1
Steven asked on 05 May 2012, 05:21 AM
In Kendo.all.js line 5123, call to get the data from the datasource is performed, but there is no check to see if the data returned is undefined.

I put in a temporary fix, but it may not be the proper way, but at least it stops Kendo from crashing.  I am posting it here to let someone know:
that.data = function(data) {
    var record,
        getter,
        idx,
        length,
        modelInstance = new that.model();
 
    data = dataFunction(data);
 
    if( isEmptyObject(data) )   // Added this fix to prevent errors if no data was returned
        return {};
         
    if (!isEmptyObject(getters) ) {
        for (idx = 0, length = data.length; idx < length; idx++) {
            record = data[idx];
            for (getter in getters) {
                record[getter] = modelInstance._parse(getter, getters[getter](record));
            }
        }
    }
 
    return data;
}

1 Answer, 1 is accepted

Sort by
0
Alexander Valchev
Telerik team
answered on 09 May 2012, 01:40 PM
Hi Steven,

As an alternative you could perform a simple check in the data function of the schema. For example:
dataSource: {
     schema: {
         data: function(data) {
             //data - the incoming data
             if (data && data.foo) {
                 return data.foo;
             }
             return [];
         }                             
     }
}

I suggest to take a look at this forum topic too as it discusses similar scenario.

Regards,
Alexander Valchev
the Telerik team
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
Tags
Data Source
Asked by
Steven
Top achievements
Rank 1
Answers by
Alexander Valchev
Telerik team
Share this question
or