Hi,
I have a radgrid with nested hierachal records, which are rows belonging to parent rows in the grid.
I was about to group the parent rows with Group by Expression with the following code
<telerik:GridGroupByExpression>
<SelectFields>
<telerik:GridGroupByField FieldAlias="Submitter" FieldName="SUBMITTER_NAME" />
</SelectFields>
<GroupByFields>
<telerik:GridGroupByField FieldName="SUBMITTER_NAME" />
</GroupByFields>
</telerik:GridGroupByExpression>
I would like to added code in the ascx file to add addition information about the number of records under the parent row before the user expanded the nested parent rows. It is help to see 0 child records or more child records so they know when to expand.
Like so: Client Name: Joe Bank, Inc, Deposit Records: 3, Withdrawal Records: 6, Acounts : 1
With the group by exression, I am not sure about to add the aggregate code to make this happen.
Can this be done in the c# code to do a query for the record count and add the label so that the user can see the number of child records before expanding the parent row?
Any help is appreciate.
I have a radgrid with nested hierachal records, which are rows belonging to parent rows in the grid.
I was about to group the parent rows with Group by Expression with the following code
<telerik:GridGroupByExpression>
<SelectFields>
<telerik:GridGroupByField FieldAlias="Submitter" FieldName="SUBMITTER_NAME" />
</SelectFields>
<GroupByFields>
<telerik:GridGroupByField FieldName="SUBMITTER_NAME" />
</GroupByFields>
</telerik:GridGroupByExpression>
I would like to added code in the ascx file to add addition information about the number of records under the parent row before the user expanded the nested parent rows. It is help to see 0 child records or more child records so they know when to expand.
Like so: Client Name: Joe Bank, Inc, Deposit Records: 3, Withdrawal Records: 6, Acounts : 1
With the group by exression, I am not sure about to add the aggregate code to make this happen.
Can this be done in the c# code to do a query for the record count and add the label so that the user can see the number of child records before expanding the parent row?
Any help is appreciate.
7 Answers, 1 is accepted
0
Hi John,
You can achieve the requested functionality on code-behind:
An alternative approach would be to use group header template:
http://demos.telerik.com/aspnet-ajax/grid/examples/groupby/headerandfootertemplates/defaultcs.aspx
I hope this will prove helpful. Please give it a try and let me know about the result.
Greetings,
Eyup
the Telerik team
You can achieve the requested functionality on code-behind:
protected
void
RadGrid1_PreRender(
object
sender, EventArgs e)
{
foreach
(GridGroupHeaderItem groupHeaderItem
in
RadGrid1.MasterTableView.GetItems(GridItemType.GroupHeader))
{
if
(!(groupHeaderItem.DataCell.Text.Contains(
"Child Items:"
)))
{
groupHeaderItem.DataCell.Text = groupHeaderItem.DataCell.Text +
"; Child Items: "
+ groupHeaderItem.GetChildItems().Length.ToString();
}
}
}
An alternative approach would be to use group header template:
http://demos.telerik.com/aspnet-ajax/grid/examples/groupby/headerandfootertemplates/defaultcs.aspx
I hope this will prove helpful. Please give it a try and let me know about the result.
Greetings,
Eyup
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
0
nguyen
Top achievements
Rank 1
answered on 20 Sep 2013, 07:17 AM
dear Eyup,
I am using your code, and the result like rawgroup.jpg
i want to count item parent group equal sum of all items of child group like groupping.jpg. How can i do like this??
please help
thank you!
I am using your code, and the result like rawgroup.jpg
i want to count item parent group equal sum of all items of child group like groupping.jpg. How can i do like this??
please help
thank you!
0
Hi Nguyen,
You can use the following approach:
Alternatively, you can use Template structure for your group headers and add count Aggregates:
http://demos.telerik.com/aspnet-ajax/grid/examples/groupby/headerandfootertemplates/defaultcs.aspx
Hope this helps. Please give it a try and let me know if it works for you.
Regards,
Eyup
Telerik
You can use the following approach:
protected
void
RadGrid1_PreRender(
object
sender, EventArgs e)
{
foreach
(GridGroupHeaderItem groupHeader
in
RadGrid1.MasterTableView.GetItems(GridItemType.GroupHeader))
{
if
(!(groupHeader.DataCell.Text.Contains(
"Child Items:"
)))
{
groupHeader.DataCell.Text = groupHeader.DataCell.Text +
"; Child Items: "
+ GetAllChildItemsCount(groupHeader);
}
}
}
private
int
GetAllChildItemsCount(GridGroupHeaderItem parentGroupHeader)
{
int
count = 0;
foreach
(GridItem gridItem
in
parentGroupHeader.GetChildItems())
{
if
(gridItem
is
GridDataItem)
{
count++;
}
else
if
(gridItem
is
GridGroupHeaderItem)
{
GridGroupHeaderItem groupHeader = (GridGroupHeaderItem)gridItem;
count += GetAllChildItemsCount(gridItem
as
GridGroupHeaderItem);
}
}
return
count;
}
Alternatively, you can use Template structure for your group headers and add count Aggregates:
http://demos.telerik.com/aspnet-ajax/grid/examples/groupby/headerandfootertemplates/defaultcs.aspx
Hope this helps. Please give it a try and let me know if it works for you.
Regards,
Eyup
Telerik
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to the blog feed now.
0
nguyen
Top achievements
Rank 1
answered on 26 Sep 2013, 06:41 AM
yeah, it work.
Thanks so much! Eyup
Thanks so much! Eyup
0
Nick
Top achievements
Rank 1
answered on 19 Nov 2013, 09:23 PM
Thanks for the code as well. Just what i was looking for!
0
Yulwenty
Top achievements
Rank 1
answered on 18 Dec 2013, 04:17 AM
0
Hi Yulwenty,
In that case, you need to use GroupHeader aggregates. You can achieve this by using GroupHeaderTemplate:
http://www.telerik.com/help/aspnet-ajax/grid-group-header-footer-templates.html
Or setting Group aggregates declaratively or programmatically as demonstrated in the attached sample.
Please run the application and let me know if it helps you.
Regards,
Eyup
Telerik
In that case, you need to use GroupHeader aggregates. You can achieve this by using GroupHeaderTemplate:
http://www.telerik.com/help/aspnet-ajax/grid-group-header-footer-templates.html
Or setting Group aggregates declaratively or programmatically as demonstrated in the attached sample.
Please run the application and let me know if it helps you.
Regards,
Eyup
Telerik
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to the blog feed now.