SfDataGrid not showing inner joined column

Hello, 

I am using Dapper and when i execute query and load to SfDataGrid only show results from first table.

Model:

public class Users

    {

        public int id { get; set; }

        public string name { get; set; }

        public string email { get; set; }

        public Roles role { get; set; }

    }

public class Roles

    {

        public int id { get; set; }

        public string name { get; set; }

    }

So when i do like

sfDataGrid1.DataSource = results; - Its only show user id, name, email without role name.

Query:

select a.*, b.name from users a inner join roles b on users.roleID = roles.id.


Tables users: id, name, email, roleID.

Table roles: id, name.


3 Replies

SS Sampathnarayanan Sankaralingam Syncfusion Team January 7, 2022 12:10 PM UTC

Hi Aleksa, 
 
Based on provided information your requirement to bind the complex property in SfDataGrid can be achieved by setting the complex property path to the MappingName in GridColumn. Please find the code snippet below, 

this.sfDataGrid1.Columns.Add(new GridTextColumn() { MappingName = "role.name", HeaderText = "Role Name" }); 
this.sfDataGrid1.Columns.Add(new GridTextColumn() { MappingName = "role.id", HeaderText = "Role ID" }); 
For more information related to Binding Complex Properties, please refer the below user guide documentation link, 

Please let us know if you have any concerns in this.
 
 
Regards, 
Sampath Narayanan.S 



AP Aleksa Petrovic January 7, 2022 05:17 PM UTC

Thanks!



SS Sampathnarayanan Sankaralingam Syncfusion Team January 10, 2022 02:48 PM UTC

Hi Aleksa,


We are glad to know that the reported problem has been resolved at your end. Please let us know if you have any further queries on this. We are happy to help you😊.


Regards,

Sampath Narayanan.S


Loader.
Up arrow icon