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

[Solved] Grouping by business object property fails - "not found in source table"

1 Answer 182 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Josh Anderson
Top achievements
Rank 1
Josh Anderson asked on 24 Jun 2008, 02:47 PM
I have a grid that's bound to a generic list of business objects.  These business objects contain a property called "Group" which is itself another business object.  This object has its ToString() method overridden.

I can display the "Group" property within the grid with no problem, but when I enable grouping and try to drag that column into the group by box I get the following error:  "Field Group not found in the source table. Please check the expression syntax."

I have another property called "PrimaryPhone" which also generates the same error if I attempt to group by that.

I can successfully group by the other non-object properties.  Any ideas on how I can accomplish grouping by these object properties?

Josh

1 Answer, 1 is accepted

Sort by
0
Josh Anderson
Top achievements
Rank 1
answered on 24 Jun 2008, 06:27 PM
I answered my own question.  In order to properly group using business objects as properties for the main business object, you must refer to the nested property directly, even if there is a "ToString()" override.

In the example from my original post, although radGrid is smart enough to use the ToString() to populate the grid's items, it can't use that for grouping.  For the "Group" property I originally described, it requires that the grouping and field naming be "Group.GroupName" — specifically addressing the subproperty I want to display and group by.  Likewise, for "PrimaryPhone" I used "PrimaryPhone.FormattedPhone" for the grouping and field definition.  Specifically:

<telerik:GridBoundColumn DataField="Group.GroupName" HeaderText="Group"></telerik:GridBoundColumn>

Hopefully this helps someone, but it would be nice if radGrid could use a ToString() override on a business object for grouping like it does for the field definition.

Josh
Tags
Grid
Asked by
Josh Anderson
Top achievements
Rank 1
Answers by
Josh Anderson
Top achievements
Rank 1
Share this question
or