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

Group By Expression - FieldName Is Through A Navigation Property

1 Answer 101 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Robin
Top achievements
Rank 1
Robin asked on 29 Apr 2014, 07:40 AM
I am using Entity Framework in this instance and would like to group my radgrid by a field located in another table related to the main item.  I have used an include statement to bring back the additional entity (one to one relationship between these tables) as lazy loading is enabled.  I want to group on "Title" field in my table "Activity"  The navigation property is "Activity1" so I have used the following to populate my datasource:

 _context.LEResults.Include("Activity1").Where(R => R.EmployeeID == EmployeeId && R.Active == true).OrderBy(E => E.AttemptDate).ToList();

I know this is working because I can display Activity1.Title as a regular gridboundcolumn.

I have got this to work before and actually have the other project in front of me but I cannot figure out what is different.  Is there anything anyone can think of that I may have missed?  The following code informs me that the field Activity1.Title is missing from my source table.

<GroupByExpressions>
                                    <telerik:GridGroupByExpression>
                                        <GroupByFields>
                                            <telerik:GridGroupByField FieldName="Activity1.Title" />
                                        </GroupByFields>
                                        <SelectFields>
                                            <telerik:GridGroupByField FieldName="Activity1.Title" HeaderText="Activity" />
                                        </SelectFields>
                                    </telerik:GridGroupByExpression>
</GroupByExpressions>


1 Answer, 1 is accepted

Sort by
0
Robin
Top achievements
Rank 1
answered on 29 Apr 2014, 07:53 AM
As fate would have it I just got this working.  I hadn't set the DataObjectTypeName in the object data source I was using.

Thanks anyway :)
Tags
Grid
Asked by
Robin
Top achievements
Rank 1
Answers by
Robin
Top achievements
Rank 1
Share this question
or