Child object properties

Hi,

Why aren't child object properties displayed when in a GridColumn?

 <GridColumn Field=@nameof(Event.Client.Name)>

When we using the syntax above the Event Client object name property should be shown but weirdly the Event name property is displayed? Do we need to use different syntax?

Thanks,

Alex


1 Reply

RN Rahul Narayanasamy Syncfusion Team January 6, 2022 11:43 AM UTC

Hi Alex,  

Greetings from Syncfusion. 

We suspect that you want to bind complex data to one of the column in the Grid. You can achieve complex data binding in the DataGrid by using the dot(.) operator in the column.field. In the following examples, Name.FirstName and Name.LastName are complex data.  

Reference

 
<SfGrid DataSource="@Employees" Height="315"> 
    <GridColumns> 
        <GridColumn Field=@nameof(EmployeeData.EmployeeID) HeaderText="EmployeeID" TextAlign="TextAlign.Right" Width="120"></GridColumn> 
        <GridColumn Field="Name.FirstName" HeaderText="First Name" Width="150"></GridColumn> 
        <GridColumn Field="Name.LastName" HeaderText="Last Name" Width="130"></GridColumn> 
        <GridColumn Field=@nameof(EmployeeData.Title) HeaderText="Title" Format="C2" TextAlign="TextAlign.Right" Width="120"></GridColumn> 
    </GridColumns> 
</SfGrid> 
 
@code{ 
    . .. 
} 


Please let us know if you have any concerns. 

Regards, 
Rahul 



Loader.
Up arrow icon