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

Error trying to group by GridAutoCompleteColumn

4 Answers 59 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Massimiliano
Top achievements
Rank 1
Massimiliano asked on 09 Nov 2013, 07:39 PM
When I try to group by a GridAutoCompleteColumn (dragging the column header in the grouping header) I get this error.
Don't know if is a known bug/limitation of that type of column or there is something messed in my implementation.

Expression cannot be null or empty
 
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
 
Exception Details: Telerik.Web.UI.GridGroupByException: Expression cannot be null or empty
 
Source Error:
 
An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.
 
Stack Trace:
 
 
[GridGroupByException: Expression cannot be null or empty]
   Telerik.Web.UI.GridGroupByExpression.SetExpression(String expression) +134
   Telerik.Web.UI.GridGroupByExpression..ctor(GridColumn column) +213
   Telerik.Web.UI.RadGrid.RaisePostBackEvent(String eventArgument) +7253
   System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +3804

4 Answers, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 1
answered on 11 Nov 2013, 12:42 PM
Hi Massimiliano,

In order to display the grid grouped by the template column, you will need to add a GroupByExpression for it too.Expressions can be defined by assigning Expression property and/or managing the items in SelectFields or GroupByFields collections. It is not required to use both of them.Please try the following code snippet.

ASPX:
<telerik:GridTemplateColumn HeaderText="ShipCountry" GroupByExpression="ShipCountry Name Group By ShipCountry">
  <ItemTemplate>
      <asp:Label ID="Label1" runat="server" Text='<%#Eval("ShipCountry") %>'></asp:Label>
  </ItemTemplate>
  <EditItemTemplate>
      <telerik:RadAutoCompleteBox ID="RadAutoCompleteBox" runat="server">
      </telerik:RadAutoCompleteBox>
  </EditItemTemplate>
</telerik:GridTemplateColumn>

Thanks,
Princy
0
Massimiliano
Top achievements
Rank 1
answered on 11 Nov 2013, 02:11 PM
Hi Princy! Thank you for your kind answer (wich will come in handy in the near future for sure!) but there has been a misunderstanding... I'm not trying to group by a GridTemplateColumn but by a GridAutoCompleteColumn.
0
Princy
Top achievements
Rank 1
answered on 12 Nov 2013, 04:01 AM
Hi Massimiliano,

You can set the GroupByExpression property for the GridAutoCompleteColumn in order group the column. Please try the following code snippet.

ASPX:
<telerik:GridAutoCompleteColumn DataField="ShipCountry" DataSourceID="SqlDataSource1"
DataTextField="ShipCountry" DataValueField="ShipCountry" HeaderText="ShipCountry"
GroupByExpression="ShipCountry Name Group By ShipCountry">
</telerik:GridAutoCompleteColumn>

Thanks,
Princy
0
Massimiliano
Top achievements
Rank 1
answered on 12 Nov 2013, 11:58 AM
Sorry Princy,
I didn't even bother to test your solution on my other type of column. It seems GridAutoCompleteColumn is considered just like template column for grouping.
Works like a charm. You are great as always! Thanks

Tags
Grid
Asked by
Massimiliano
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 1
Massimiliano
Top achievements
Rank 1
Share this question
or