This is a migrated thread and some comments may be shown as answers.
Grid Grouping causes Uncaught TypeError: Cannot read property 'Name' of null
1 Answer 37 Views
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
GT
Top achievements
Rank 1
GT asked on 11 Jan 2012, 10:30 PM
I have a grid with ajax databinding enabled. Sorting, filtering, and paging work fine, however when grouping is enabled it generates the following client side error: Uncaught TypeError: Cannot read property 'Name' of null.

The grid is defined as:
@(Html.Telerik().Grid<MyObject>()
    .Name("MyObjectGrid")
    .Columns(columns =>
        {
            columns.Bound(o => o.Foo.Name).Title("Foo").Width(500);
            columns.Bound(o => o.Bar.Name).Title("Bar").Width(100);
            columns.Bound(o => o.Prop1).Width(100);
            columns.Bound(o => o.Prop2).Width(100);
        })
    .DataBinding(dataBinding =>
        {
            dataBinding.Ajax().Select(
                "GetMyObjects",
                "MyObjectsController",
                new
                {
                    MyRoutingParameter = Model.SomeRoutingParameter,
                });
        })
        .Scrollable()
        .Sortable()
        .Pageable()
        .Filterable()
        .Groupable())

And the controller is defined as:
[HttpPost]
[GridAction]
public JsonResult GetMyObjects(MyObjectCriteria criteria)
{
    var result = this.repository.GetMyObjects(criteria);
    return new JsonResult { Data = new GridModel(result) };
}

The repository.GetMyObjects method returns an IQueryable and I'm using the EntityFramework (4.2). Again, sorting, filtering, and paging work fine, this only occurs when enabling grouping.

Any thoughts/suggestions to help track this down?

Thanks!

1 Answer, 1 is accepted

Sort by
0
Petur Subev
Telerik team
answered on 13 Jan 2012, 03:33 PM
Hi Greg,

As the exception message describes the problem, probably the Foo or Bar properties are null. The Grid does not handle such cases. Make sure that every MyObject in your collection has instances of the Foo and Bar properties.

Greetings,
Petur Subev
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the Telerik Extensions for ASP.MET MVC, subscribe to their blog feed now
Tags
Grid
Asked by
GT
Top achievements
Rank 1
Answers by
Petur Subev
Telerik team
Share this question
or