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

How do i bound null object value

1 Answer 1200 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Fatih
Top achievements
Rank 1
Fatih asked on 19 Oct 2012, 08:59 AM
Hi I am trying to

columns.Bound(f => f.Admin_Menu_Group.Name ).Title("Admin Menu Group");
or
columns.Bound(f => f.Admin_Menu_Group != null ? f.Admin_Menu_Group.Name : "").Title("Admin Menu Group");

But error "Bound columns require a field or property access expression"

Because Admin.Menu.Group field is null.

1 Answer, 1 is accepted

Sort by
1
Petur Subev
Telerik team
answered on 24 Oct 2012, 07:23 AM
Hello Fatih,

Basically the problem is not to bind the column to a property of nullable object - the problem is when the Grid tries to access it (i.e. when it is displayed).
If your Grid is using Ajax binding you can set a ClientTemplate like the following where Brother could be null:

columns.Bound(c => c.Brother.Name).ClientTemplate(" #= Brother ? Brother.Name : '' # ").Title("Brother");


Kind Regards,
Petur Subev
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
Fatih
Top achievements
Rank 1
Answers by
Petur Subev
Telerik team
Share this question
or