Grouping by column in RadGrid

2 posts, 0 answers
  1. LH
    LH avatar
    4 posts
    Member since:
    Jun 2009

    Posted 12 Jul 2009 Link to this post

    Hi,
    I have a SPDataSource which connected to SPList with title and choice columns (choice column name - "Choice").
    I'm trying to group the grid MainTableView by the column 'Choice'.
    I tried to do that with the GridGroupByExpression (With the column Ctor), and I get an error: "Field Choice not found in the source table. Please check expression syntax".
    here's a code snippet:
    "
    ridBoundColumn colToGroup = (GridBoundColumn)this.myGrid.MasterTableView.Columns.FindByDataField("Choice");
    GridGroupByExpression expr = new GridGroupByExpression(colToGroup);
    this.myGrid.MasterTableView.GroupByExpressions.Add(expr);
    this.myGrid.MasterTableView.DataBind();
      // Here the eror thrown.
    "

    Furthermore, I tried to build the group expression without the Ctor and I got the same error.

    I would like some direction in the issue...

    Thank You,
    Neta
  2. Sebastian
    Admin
    Sebastian avatar
    9934 posts

    Posted 14 Jul 2009 Link to this post

    Hello LH,

    The proper method to build group by expressions for RadGrid for ASP.NET AJAX is demonstrated in these online resources:

    http://demos.telerik.com/aspnet-ajax/grid/examples/groupby/expressions/defaultcs.aspx
    http://www.telerik.com/help/aspnet-ajax/grdgroupbyprogrammaticdefinition.html

    Note that you need to specify at least one select field and one group by field for the newly created expression in order to be evaluated properly.

    Additionally, you can test whether the manually created SELECT ... GROUP BY query is executed successfully by the SPDataSource when using regular MS GridView instance.

    Best regards,
    Sebastian
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.

Back to Top