This question is locked. New answers and comments are not allowed.
Hi Guys,
I am having an issue displaying values when the child object is null in the client template. I am using the telerik MVC grid of the 2011.3.1115 release in MVC3 with razor.
I am trying to display a list of projects in the telerik mvc grid and the employees first name but some projects do not have an employee assigned to them so the value is null. This throws a javascript error when I try to access the value in the client template
"Microsoft JScript runtime error: Unable to get value of the property 'FirstName': object is null or undefined".
Is their a way to work around this or check if the employee is null and display string.empty using the razor syntax? I've attached some sample code below. Any help would be greatly appreciated!
Thanks
Ex: I have an object called Project with an employee property of type employee set up as below.
here is the grid I am using.
I am having an issue displaying values when the child object is null in the client template. I am using the telerik MVC grid of the 2011.3.1115 release in MVC3 with razor.
I am trying to display a list of projects in the telerik mvc grid and the employees first name but some projects do not have an employee assigned to them so the value is null. This throws a javascript error when I try to access the value in the client template
"Microsoft JScript runtime error: Unable to get value of the property 'FirstName': object is null or undefined".
Is their a way to work around this or check if the employee is null and display string.empty using the razor syntax? I've attached some sample code below. Any help would be greatly appreciated!
Thanks
Ex: I have an object called Project with an employee property of type employee set up as below.
public class Project { public Employee Employee { get; set; }public string ProjectName { get; set; }}
public class Employee { public string FirstName { get; set; } }
here is the grid I am using.
@( Html.Telerik().Grid<ViewModels.ProjectView>() .Name("Grid") .ColumnContextMenu() .Columns(columns => { columns.Bound(o => o.Project.Project.ProjectName); columns.Bound(o => o.Project.Employee.FirstName).ClientTemplate("<#= Employee.FirstName#>").Title("PA"); }) .DataBinding(dataBinding => { dataBinding.Ajax().OperationMode(GridOperationMode.Client) .Select("_MyProjectsGrid", "Projects"); }) .Sortable() .Filterable() .Pageable(p => p.PageSize(20)) .Resizable(r => r.Columns(true)) .NoRecordsTemplate("You have no deliverables at this time.")