5 Answers, 1 is accepted
0
Hi Mike,
There are several ways to do that. The easiest one is to add an aggregate to the bound column like this:
This can also be performed in the code-behind:
Do not forget to set ShowFooter = true for the grid in order to render footers for its columns.
Best regards,
Daniel
the Telerik team
Instantly find answers to your questions at the new Telerik Support Center
There are several ways to do that. The easiest one is to add an aggregate to the bound column like this:
<telerik:GridBoundColumn Aggregate="Count" DataField="ShipName" HeaderText="ShipName" |
SortExpression="ShipName" UniqueName="ShipName"> |
</telerik:GridBoundColumn> |
This can also be performed in the code-behind:
GridBoundColumn gBoundColumn = RadGrid1.MasterTableView.GetColumn("myColumn") as GridBoundColumn; |
gBoundColumn.Aggregate = GridAggregateFunction.Count; |
Do not forget to set ShowFooter = true for the grid in order to render footers for its columns.
Best regards,
Daniel
the Telerik team
Instantly find answers to your questions at the new Telerik Support Center
0

Mike
Top achievements
Rank 1
answered on 04 Jul 2008, 12:43 PM
I definately like the code behind solution better, but I have a couple questions.
1. Is there a way to put the count in the header and not the footer?
Thank You!
1. Is there a way to put the count in the header and not the footer?
Thank You!
0

Princy
Top achievements
Rank 2
answered on 05 Jul 2008, 05:51 AM
Hi Mike,
Give a try with the following approach and see whether it works.
ASPX:
CS:
Thanks
Princy.
Give a try with the following approach and see whether it works.
ASPX:
<telerik:radgrid id="RadGrid1" runat="server" ShowFooter="true" Width="500px" > |
<MasterTableView DataSourceID="SqlDataSource1"> |
<Columns> |
<telerik:GridBoundColumn UniqueName="ProductName" Aggregate="Count" DataField="ProductName" HeaderText="ProductName" > |
</telerik:GridBoundColumn> |
</Columns> |
</MasterTableView> |
</telerik:radgrid> |
CS:
string strCount; |
protected void RadGrid1_ItemDataBound(object sender, Telerik.Web.UI.GridItemEventArgs e) |
{ |
if (e.Item is GridFooterItem) |
{ |
GridFooterItem footer = (GridFooterItem)e.Item; |
strCount = footer["ProductName"].Text.ToString(); |
} |
} |
protected void RadGrid1_PreRender(object sender, EventArgs e) |
{ |
foreach (GridHeaderItem header in RadGrid1.MasterTableView.GetItems(GridItemType.Header)) |
{ |
header["ProductName"].Text = strCount; |
} |
} |
Thanks
Princy.
0
Accepted
Hello Mike,
The above given example should work, but you have to notice that this will override your current column name. It is also possible to simplify this in order to make it more easier and more faster.
Kind regards,
Daniel
the Telerik team
Instantly find answers to your questions at the new Telerik Support Center
The above given example should work, but you have to notice that this will override your current column name. It is also possible to simplify this in order to make it more easier and more faster.
protected void RadGrid1_PreRender(object sender, EventArgs e) |
{ |
foreach (GridHeaderItem headerItem in RadGrid1.MasterTableView.GetItems(GridItemType.Header)) |
headerItem["yourColumn"].Text += " " + RadGrid1.MasterTableView.Items.Count.ToString(); |
} |
Kind regards,
Daniel
the Telerik team
Instantly find answers to your questions at the new Telerik Support Center
0

Mike
Top achievements
Rank 1
answered on 07 Jul 2008, 04:23 PM
Thank you Daniel!