Dhamodharan
Top achievements
Rank 1
Dhamodharan
asked on 08 Sep 2011, 10:45 AM
Hi,
I am using radgrid grouping. i want to display the count in header based on grouping. i have attached image please check,
(ie) i want to display count same as footer count. please check the image,
i am using the code
For Each item As GridGroupHeaderItem In rgDetailGroup.MasterTableView.GetItems(GridItemType.GroupHeader)
Dim grpHdrText As String() = item.DataCell.Text.Split("-")
item.DataCell.Text = (grpHdrText(0) + "-" + item.GetChildItems().Length.ToString)
Next
This code returns count correctly if i selected one grouping. but selecting another grouping second header count looks good. but first header not shown correct count. please help for this one,
Thanks in Advance,
Dhamu.
I am using radgrid grouping. i want to display the count in header based on grouping. i have attached image please check,
(ie) i want to display count same as footer count. please check the image,
i am using the code
For Each item As GridGroupHeaderItem In rgDetailGroup.MasterTableView.GetItems(GridItemType.GroupHeader)
Dim grpHdrText As String() = item.DataCell.Text.Split("-")
item.DataCell.Text = (grpHdrText(0) + "-" + item.GetChildItems().Length.ToString)
Next
This code returns count correctly if i selected one grouping. but selecting another grouping second header count looks good. but first header not shown correct count. please help for this one,
Thanks in Advance,
Dhamu.
8 Answers, 1 is accepted
0
Hello Dhamodharan,
An easier way to achieve the same functionality is to use the bullt-in GroupHeader aggregates. This will help you avoid the unnecessary calculations.
I am attaching a sample project to illustrate this approach.
Kind regards,
Andrey
the Telerik team
Check out Telerik Trainer, the state of the art learning tool for Telerik products.
An easier way to achieve the same functionality is to use the bullt-in GroupHeader aggregates. This will help you avoid the unnecessary calculations.
I am attaching a sample project to illustrate this approach.
Kind regards,
Andrey
the Telerik team
Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
Dhamodharan
Top achievements
Rank 1
answered on 13 Sep 2011, 04:35 PM
Hello Andrey,
I want display items count in header based on grouping. please see the attached image in previous post. please let me know if you have any idea about that one,
Thanks in Advance,
Dhamu.
I want display items count in header based on grouping. please see the attached image in previous post. please let me know if you have any idea about that one,
Thanks in Advance,
Dhamu.
0
Accepted
Hello Dhamodharan,
I modified the sample project to illustrate how you can achieve the desired functionality.
Review the following help topics for additional information:
GroupBy Expression
Declarative definition of GroupBy Expressions
Programmatic creation of GroupBy Expressions
There you could find how to customize the demonstrated approach so it fully suits your requirements.
Regards,
Andrey
the Telerik team
I modified the sample project to illustrate how you can achieve the desired functionality.
Review the following help topics for additional information:
GroupBy Expression
Declarative definition of GroupBy Expressions
Programmatic creation of GroupBy Expressions
There you could find how to customize the demonstrated approach so it fully suits your requirements.
Regards,
Andrey
the Telerik team
Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal
0
Dhamodharan
Top achievements
Rank 1
answered on 14 Sep 2011, 04:51 PM
Hi Andrey,
This is what i need. looks good. thanks for your help.
Thanks,
Dhamu
This is what i need. looks good. thanks for your help.
Thanks,
Dhamu
0
nguyen
Top achievements
Rank 1
answered on 17 Sep 2013, 03:59 AM
Hello Andrey,
your sample is good , but when i am using grid with dinamic column. perhaps we should count item in code behind.
How can i count when using code behind?
Here is my code:
protected void grid_OnPreRender(object sender, EventArgs e)
{
foreach (GridGroupHeaderItem groupHeader in grid.MasterTableView.GetItems(GridItemType.GroupHeader))
{
GridItem[] children = groupHeader.GetChildItems();
_count = children.Count();
groupHeader.DataCell.Text = "Count=" + _count.ToString();
_count = 0;
}
}
thank you!
your sample is good , but when i am using grid with dinamic column. perhaps we should count item in code behind.
How can i count when using code behind?
Here is my code:
protected void grid_OnPreRender(object sender, EventArgs e)
{
foreach (GridGroupHeaderItem groupHeader in grid.MasterTableView.GetItems(GridItemType.GroupHeader))
{
GridItem[] children = groupHeader.GetChildItems();
_count = children.Count();
groupHeader.DataCell.Text = "Count=" + _count.ToString();
_count = 0;
}
}
thank you!
0
Hi Nguyen,
I am not sure that I fully understand the requirement but I suppose that you want to obtain the total number of items for a specific group. This is achievable by subscribing to the ItemDataBound event and executing the below shown logic:
You can store the counts in a dictionary for example and later in the PreRender event of the grid modify the header cells text.
Regards,
Angel Petrov
Telerik
I am not sure that I fully understand the requirement but I suppose that you want to obtain the total number of items for a specific group. This is achievable by subscribing to the ItemDataBound event and executing the below shown logic:
public
void
RadGrid1_ItemDataBound(
object
sender, Telerik.Web.UI.GridItemEventArgs e)
{
if
(e.Item
is
GridGroupHeaderItem) {
GridGroupHeaderItem item = (GridGroupHeaderItem)e.Item;
DataRowView groupDataRow = (DataRowView)e.Item.DataItem;
int
count=
int
.Parse(groupDataRow[
"count"
]);
}
}
You can store the counts in a dictionary for example and later in the PreRender event of the grid modify the header cells text.
Regards,
Angel Petrov
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 24 Sep 2013, 04:12 AM
Hello angel Petrov,
i get error from your code
count is neither a DataColumn nor a DataRelation for table GroupedTable0.
i can find the count from where?
i get error from your code
count is neither a DataColumn nor a DataRelation for table GroupedTable0.
i can find the count from where?
0
Hello Nguyen,
Please try the following:
If that does not help to extract the item count I would like to ask you to share with us the markup and code-behind of the page so we could get a better understanding of the problem.
Regards,
Angel Petrov
Telerik
Please try the following:
protected
void
RadGrid1_ItemDataBound(
object
sender, GridItemEventArgs e)
{
if
(e.Item
is
GridGroupHeaderItem)
{
GridGroupHeaderItem item = (GridGroupHeaderItem)e.Item;
DataRowView groupDataRow = (DataRowView)e.Item.DataItem;
int
count =
int
.Parse(groupDataRow.Row.ItemArray[0].ToString());
}
}
Regards,
Angel Petrov
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.