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

"Invalid group by expression: Group By clause missing" error when grouping a GridTemplateColumn

6 Answers 486 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Joe Kalinowski
Top achievements
Rank 1
Joe Kalinowski asked on 14 Sep 2010, 03:58 PM
I receive a "Invalid group by expression: Group By clause missing" when grouping a GridTemplateColumn. However, if I set that same column as a GridBoundColumn, grouping works correctly. Also, if I set the GridTemplateColumn to be grouped by default the GroupByExpressions collection, it is grouped properly, but then if I remove the grouping and drag the column to be grouped again, it fails with the same error.

If I remove the GroupByExpression from the GridTemplateColumn definition and try to group by dragging, I get a "Telerik.Web.UI.GridGroupByException: Expression cannot be null or empty" error.

GridBoundColumn definition that works:

<

 

 

telerik:GridBoundColumn

 

 

 

UniqueName="School1"

 

 

 

SortExpression="School"

 

 

 

DataField="School"

 

 

 

HeaderText="School"

 

 

 

AllowFiltering="true"

 

 

 

Groupable="true"

 

 

 

HeaderStyle-Width="75"

 

 

 

ItemStyle-Width="75"

 

 

 

FooterStyle-Width="75"/>

 


GridTemplateColumn defination that fails (with GroupByExpression="School" I get "Invalid group by expression: Group By clause missing" and without it I get "Telerik.Web.UI.GridGroupByException: Expression cannot be null or empty":

<

 

 

telerik:GridTemplateColumn

 

 

 

UniqueName="School2"

 

 

 

SortExpression="School"

 

 

 

DataField="School"

 

 

 

HeaderText="School"

 

 

 

AllowFiltering="true"

 

 

 

Groupable="true"

 

 

 

HeaderStyle-Width="75"

 

 

 

ItemStyle-Width="75"

 

 

 

FooterStyle-Width="75">

 

 

 

<ItemTemplate>

 

<%

 

# Eval("School") %>

 

 

 

</ItemTemplate>
</telerik:GridTemplateColumn>

 


6 Answers, 1 is accepted

Sort by
0
Joe Kalinowski
Top achievements
Rank 1
answered on 14 Sep 2010, 04:23 PM
So it appears that my syntax for the GroupByExpression property was incorrect. It should be GroupByExpression="School Group By School" instead of

 

GroupByExpression

 

 

="School". So the question is - why is a GroupByExpression required for a GridTemplateColumn but not a GridBoundColumn?

0
Mira
Telerik team
answered on 14 Sep 2010, 04:26 PM
Hello Joe,

Please try setting GroupByExpression="School Group By School"  to the template column and let me know whether it helps.

Greetings,
Mira
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Joe Kalinowski
Top achievements
Rank 1
answered on 14 Sep 2010, 04:33 PM
Yes, it did fix the issue. According to the documentation, this should not be necessary. And it is not necessary with a GridBoundColumn.

From the documentation:
The group-expression that should be used when grid is grouping-by this column. If not set explicitly, RadGrid will generate a group expression based on the DataField of the column (if available), using the GridColumn.GetDefaultGroupByExpression method.
0
Joe Kalinowski
Top achievements
Rank 1
answered on 14 Sep 2010, 04:54 PM
Can a format string be included in the GroupByExpression syntax? I don't see anything about that in the documentation.
0
Mira
Telerik team
answered on 15 Sep 2010, 09:53 AM
Hello Joe,

Straight to your questions:
  1. The cited functionality is valid for all columns except the template ones. I have notified our help team about this lapse in the documentation and they are already  working on it.
  2. The desired behavior can be implemented using the FormatString property.

I hope this helps.

Sincerely yours,
Mira
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Dave
Top achievements
Rank 1
answered on 18 May 2011, 08:53 PM
This solution worked for me too.  Thx!  :)
Tags
Grid
Asked by
Joe Kalinowski
Top achievements
Rank 1
Answers by
Joe Kalinowski
Top achievements
Rank 1
Mira
Telerik team
Dave
Top achievements
Rank 1
Share this question
or