Error trying to group by GridAutoCompleteColumn

5 posts, 0 answers
  1. Massimiliano
    Massimiliano avatar
    185 posts
    Member since:
    Oct 2012

    Posted 09 Nov 2013 Link to this post

    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
  2. Princy
    Princy avatar
    17421 posts
    Member since:
    Mar 2007

    Posted 11 Nov 2013 Link to this post

    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
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Massimiliano
    Massimiliano avatar
    185 posts
    Member since:
    Oct 2012

    Posted 11 Nov 2013 Link to this post

    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.
  5. Princy
    Princy avatar
    17421 posts
    Member since:
    Mar 2007

    Posted 11 Nov 2013 Link to this post

    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
  6. Massimiliano
    Massimiliano avatar
    185 posts
    Member since:
    Oct 2012

    Posted 12 Nov 2013 Link to this post

    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

Back to Top
UI for ASP.NET Ajax is Ready for VS 2017