Hi, is it possible to assign an aggregate to an autogenerated column and if so how can I do it. I haven't found an example and I don't see how to do it in the ColumnCreating or ColumnCreated events. Hopefully these can also be exported to excel.
Thanks.
Thanks.
8 Answers, 1 is accepted
0
Princy
Top achievements
Rank 2
answered on 20 Apr 2009, 03:45 AM
Hello Darren,
You can try out the following code to set the aggregate function for columns:
c#:
NB: Also set the ShowFooter property of the grid to true.
Thanks
Princy.
You can try out the following code to set the aggregate function for columns:
c#:
protected void RadGrid1_ColumnCreated(object sender, GridColumnCreatedEventArgs e) |
{ |
if (e.Column is GridBoundColumn) |
{ |
(e.Column as GridBoundColumn).Aggregate = GridAggregateFunction.Count; |
} |
} |
// use the same logic for other column types that support aggregates |
Thanks
Princy.
0
Darren
Top achievements
Rank 1
answered on 20 Apr 2009, 04:07 AM
Hi, thanks for the reply. When i try this and enable the footer I am getting an error. if i don't display the footer i don't get the error.
Exception Details: System.Data.EvaluateException: Cannot find column [hs_grad_year].
Source Error:
Stack Trace:
Cannot find column [hs_grad_year].
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: System.Data.EvaluateException: Cannot find column [hs_grad_year].
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:
|
0
Shinu
Top achievements
Rank 2
answered on 20 Apr 2009, 07:02 AM
Hi Darren,
Are you using a hierarchical RadGrid? Is your grid having a column named 'hs_grad_year' ? if so is it in the detail table or master table?
Shinu
Are you using a hierarchical RadGrid? Is your grid having a column named 'hs_grad_year' ? if so is it in the detail table or master table?
Shinu
0
Darren
Top achievements
Rank 1
answered on 20 Apr 2009, 01:44 PM
It is a regular 1 level grid and the column exists, autogenerated. Thanks.
0
Princy
Top achievements
Rank 2
answered on 23 Apr 2009, 08:50 AM
Hi,
Could you please post your aspx here as I am not able to replicate the issue. I have tried the code snippet by Shinu abnd it is working fine on my end,
Thanks,
Princy
Could you please post your aspx here as I am not able to replicate the issue. I have tried the code snippet by Shinu abnd it is working fine on my end,
Thanks,
Princy
0
Fabian Raul Jofre
Top achievements
Rank 2
answered on 19 Oct 2009, 10:12 PM
I have excacttly the same mistake.
Do you have a solution for this?
This happend if your columns are generated dinamycally.
Example:
Fisrt Time Datasource:
Column1 | Colum2 | Column3
First time everything is ok.
Second Time
Column1 | Column3 | Column4
Here is the problem. The "Column 4"
The first time Column2 didn´t exist.
Exepcion:
- Origen: System.Data
- Mensaje: No se puede encontrar la columna [RET. FED. IMP].
- StackTrace: en System.Data.AggregateNode.Bind(DataTable table, List`1 list)
en System.Data.DataExpression.Bind(DataTable table)
en System.Data.DataExpression..ctor(DataTable table, String expression, Type type)
en System.Data.DataTable.Compute(String expression, String filter)
en Telerik.Web.UI.GridBoundColumn.ApplyAggregates(TableCell cell, String footerText)
en Telerik.Web.UI.GridBoundColumn.cell_DataBinding(Object sender, EventArgs e)
en System.Web.UI.Control.OnDataBinding(EventArgs e)
en System.Web.UI.Control.DataBind(Boolean raiseOnDataBinding)
en System.Web.UI.Control.DataBind()
en System.Web.UI.Control.DataBindChildren()
en System.Web.UI.Control.DataBind(Boolean raiseOnDataBinding)
en System.Web.UI.Control.DataBind()
en Telerik.Web.UI.GridItem.SetupItem(Boolean dataBind, Object dataItem, GridColumn[] columns, ControlCollection rows)
en Telerik.Web.UI.GridTableView.CreateFooterItem(Boolean useDataSource, GridColumn[] copiedColumnSet, GridTFoot tfoot)
en Telerik.Web.UI.GridTableView.CreateControlHierarchy(Boolean useDataSource)
en Telerik.Web.UI.GridTableView.CreateChildControls(IEnumerable dataSource, Boolean useDataSource)
en System.Web.UI.WebControls.CompositeDataBoundControl.PerformDataBinding(IEnumerable data)
en System.Web.UI.WebControls.DataBoundControl.OnDataSourceViewSelectCallback(IEnumerable data)
en System.Web.UI.DataSourceView.Select(DataSourceSelectArguments arguments, DataSourceViewSelectCallback callback)
en System.Web.UI.WebControls.DataBoundControl.PerformSelect()
en Telerik.Web.UI.GridTableView.PerformSelect()
en System.Web.UI.WebControls.BaseDataBoundControl.DataBind()
en Telerik.Web.UI.GridTableView.DataBind()
en Telerik.Web.UI.RadGrid.DataBind()
en Reporte_Cierre_Puntos_Mensual.ArmarTabla() en c:\Documents and Settings\arielr.INTRANET\mis documentos\visual studio 2008\websites\virtualcash\Reporte_Cierre_Puntos_Mensual.aspx.cs:lÃnea 165
Do you have a solution for this?
This happend if your columns are generated dinamycally.
Example:
Fisrt Time Datasource:
Column1 | Colum2 | Column3
First time everything is ok.
Second Time
Column1 | Column3 | Column4
Here is the problem. The "Column 4"
The first time Column2 didn´t exist.
Exepcion:
- Origen: System.Data
- Mensaje: No se puede encontrar la columna [RET. FED. IMP].
- StackTrace: en System.Data.AggregateNode.Bind(DataTable table, List`1 list)
en System.Data.DataExpression.Bind(DataTable table)
en System.Data.DataExpression..ctor(DataTable table, String expression, Type type)
en System.Data.DataTable.Compute(String expression, String filter)
en Telerik.Web.UI.GridBoundColumn.ApplyAggregates(TableCell cell, String footerText)
en Telerik.Web.UI.GridBoundColumn.cell_DataBinding(Object sender, EventArgs e)
en System.Web.UI.Control.OnDataBinding(EventArgs e)
en System.Web.UI.Control.DataBind(Boolean raiseOnDataBinding)
en System.Web.UI.Control.DataBind()
en System.Web.UI.Control.DataBindChildren()
en System.Web.UI.Control.DataBind(Boolean raiseOnDataBinding)
en System.Web.UI.Control.DataBind()
en Telerik.Web.UI.GridItem.SetupItem(Boolean dataBind, Object dataItem, GridColumn[] columns, ControlCollection rows)
en Telerik.Web.UI.GridTableView.CreateFooterItem(Boolean useDataSource, GridColumn[] copiedColumnSet, GridTFoot tfoot)
en Telerik.Web.UI.GridTableView.CreateControlHierarchy(Boolean useDataSource)
en Telerik.Web.UI.GridTableView.CreateChildControls(IEnumerable dataSource, Boolean useDataSource)
en System.Web.UI.WebControls.CompositeDataBoundControl.PerformDataBinding(IEnumerable data)
en System.Web.UI.WebControls.DataBoundControl.OnDataSourceViewSelectCallback(IEnumerable data)
en System.Web.UI.DataSourceView.Select(DataSourceSelectArguments arguments, DataSourceViewSelectCallback callback)
en System.Web.UI.WebControls.DataBoundControl.PerformSelect()
en Telerik.Web.UI.GridTableView.PerformSelect()
en System.Web.UI.WebControls.BaseDataBoundControl.DataBind()
en Telerik.Web.UI.GridTableView.DataBind()
en Telerik.Web.UI.RadGrid.DataBind()
en Reporte_Cierre_Puntos_Mensual.ArmarTabla() en c:\Documents and Settings\arielr.INTRANET\mis documentos\visual studio 2008\websites\virtualcash\Reporte_Cierre_Puntos_Mensual.aspx.cs:lÃnea 165
0
Hello Fabian,
From the stack trace of the error you provided tt seems that in your case the aggregates for your columns cannot be generated at a certain stage of the grid lifecycle. Can you please verify that the columns are generated programmatically in par with the concepts explained in this documentation topic? This will ensure that their lifecycle and viewstate will remain consistent and the aggregates should be calculated as expected.
Best regards,
Sebastian
the Telerik team
Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
From the stack trace of the error you provided tt seems that in your case the aggregates for your columns cannot be generated at a certain stage of the grid lifecycle. Can you please verify that the columns are generated programmatically in par with the concepts explained in this documentation topic? This will ensure that their lifecycle and viewstate will remain consistent and the aggregates should be calculated as expected.
Best regards,
Sebastian
the Telerik team
Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
Danyal Rashid
Top achievements
Rank 1
answered on 07 Mar 2012, 05:11 PM
For anyone else coming across this issue, following info might help
We came across this issue after we upgraded 2009.3.1103.35 to 2011.3.1115.35
Our scenario:
- Custom user control ucGrid that contains our RadGrid along with some other asp.net controls. Entire ucGrid is ajaxified and data is populated using RadGrid.DataBind during an Ajax request.
- RadGrid has 2-3 predefined template columns such as checkboxes and images (defined in aspx page with MasterTableView AutoGenerateColumns="False"
- All data columns (custom class that inherits from GridBoundColumn) populated during Page Load event (!IsPostback).
- All properties set AFTER adding the column to MasterTableView as recommended. Some columns have aggregate properties set
- Some additonal properties are set using MasterTableView.GetColumn
- etc. etc. etc.
All works fine as expected in 2009.3.1103.35 but not in 2011.3.1115.35
* MasterTableView.GetColumn does not work, MasterTableView.Columns.FindByUniqueName works
* Exception that column is not found in System.Data.AggregateNode.Bind method
Upgrading to Q3 2011 SP1 2011.3.1305.35 fixed both issues. Issue 1 is actually documented in release notes (http://www.telerik.com/products/aspnet-ajax/whats-new/release-history/q3-2011-sp1-version-2011-3-1305.aspx).
It would have been nice to document the aggregate exception issue as well.
Thanks
We came across this issue after we upgraded 2009.3.1103.35 to 2011.3.1115.35
Our scenario:
- Custom user control ucGrid that contains our RadGrid along with some other asp.net controls. Entire ucGrid is ajaxified and data is populated using RadGrid.DataBind during an Ajax request.
- RadGrid has 2-3 predefined template columns such as checkboxes and images (defined in aspx page with MasterTableView AutoGenerateColumns="False"
- All data columns (custom class that inherits from GridBoundColumn) populated during Page Load event (!IsPostback).
- All properties set AFTER adding the column to MasterTableView as recommended. Some columns have aggregate properties set
- Some additonal properties are set using MasterTableView.GetColumn
- etc. etc. etc.
All works fine as expected in 2009.3.1103.35 but not in 2011.3.1115.35
* MasterTableView.GetColumn does not work, MasterTableView.Columns.FindByUniqueName works
* Exception that column is not found in System.Data.AggregateNode.Bind method
Upgrading to Q3 2011 SP1 2011.3.1305.35 fixed both issues. Issue 1 is actually documented in release notes (http://www.telerik.com/products/aspnet-ajax/whats-new/release-history/q3-2011-sp1-version-2011-3-1305.aspx).
It would have been nice to document the aggregate exception issue as well.
Thanks