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

[Solved] How to do Grouping

3 Answers 135 Views
Grid
This is a migrated thread and some comments may be shown as answers.
TMLP
Top achievements
Rank 1
TMLP asked on 03 Dec 2009, 01:18 AM
Hi there,

I've been working to get my grouping working like this example: http://demos.telerik.com/aspnet-ajax/grid/examples/groupby/outlookstyle/defaultcs.aspx

Here's my code..
<telerik:RadGrid ID="PopularProductGrid" runat="server">  
   <MasterTableView AutoGenerateColumns="false">  
      <GroupByExpressions> 
         <telerik:GridGroupByExpression> 
            <SelectFields> 
                <telerik:GridGroupByField FieldName="productName" HeaderText="Product"/>  
             </SelectFields> 
             <GroupByFields> 
                 <telerik:GridGroupByField FieldName="productName" /> 
             </GroupByFields> 
          </telerik:GridGroupByExpression> 
      </GroupByExpressions> 
      <Columns> 
          <telerik:GridBoundColumn DataField="productName" HeaderText="Product"></telerik:GridBoundColumn> 
          <telerik:GridBoundColumn DataField="customerName" HeaderText="Customer"></telerik:GridBoundColumn> 
       </Columns> 
    </MasterTableView> 
</telerik:RadGrid> 

And on ASPX.CS, I've set DataSource and did DataBind(). The grid appears okay with correct data when there is no <GroupByExpressions> section of the code. Once I add this section of code, I get an server error: "Column 'productName' does not belong to table
" Am I missing something here??

Thanks..

3 Answers, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 03 Dec 2009, 06:08 AM
Hello Loya,

For advanced features like grouping the RadGrid requires advanced data-binding through its NeedDataSource event or a data source control. Thus, can you place the code for binding the grid in the NeedDataSource event of the grid and see if it helps. Here's a link to an online demo on advanced data-binding techniques:
Advanced Data Binding

Thanks
Princy.
0
TMLP
Top achievements
Rank 1
answered on 03 Dec 2009, 05:09 PM
Hi Princy,

Thanks for your reply. I've added NeedDataSource eventhandler. This is additional code I've added:
On Grid control, I added :   
OnNeedDataSource="Grid_NeedDataSource" 

On aspx.cs I added:

protected void Grid_NeedDataSource(object source, Telerik.Web.UI.GridNeedDataSourceEventArgs e)   
{  
Grid.DataSource = myTable.Select("... some code");   
}  
 
 



Even after that, I am experiencing the exactly same behavior as I've described in the posting... Why does it say Column 'productName' does not belong to table????

 

 

 

 

0
TMLP
Top achievements
Rank 1
answered on 03 Dec 2009, 07:29 PM
I figured out. The problem was the data source. It didn't have the columns defined although the data was stored in a correct order. Thanks.
Tags
Grid
Asked by
TMLP
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
TMLP
Top achievements
Rank 1
Share this question
or