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

[Solved] SOLUTION: Manual Databinding a NULL JSON object to the MVC grid fails

0 Answers 91 Views
Grid
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
charles
Top achievements
Rank 1
charles asked on 29 Feb 2012, 02:13 PM
This is in regards to 2011.2.629.  Not sure if it's been fixed in the latest builds.  I am using Entity Framework 4.

I've been banging my head against my desk for a couple of days now.  I am currently binding one of my grids manually to a JSON object result set, using the grid.dataBind(result) method.  The binding works fine so long as there are results...if I try to databind to null, I get a "length is null or undefined" error from jQuery 1.6.2.

To make a long story short, the problem is in telerik.common.js, here:
_idMap: function (data)
{
  var that = this, id = that.id, idx, length, map = {};
  if (id){
    for (idx = 0, length = data.length; idx < length; idx++){
      map[id(data[idx])] = idx;
    }
  }
that._map = map;
},

Change it to look like this:
_idMap: function (data)
{
  var that = this, id = that.id, idx, length, map = {};
  if (data != null){
    if (id){
      for (idx = 0, length = data.length; idx < length; idx++){
        map[id(data[idx])] = idx;
      }
    }
  }
that._map = map;
},

Tags
Grid
Asked by
charles
Top achievements
Rank 1
Share this question
or