Chris Thierry
Top achievements
Rank 1
Chris Thierry
asked on 09 Sep 2010, 07:34 PM
Hi,
Is there a possibility to collapse/expand a group level in radgridview UI ?
example: radgridview grouped by date
2010/01/01
row1
row2
row3
2010/01/02
row4
row5
row6
row7
I want to collapse the date group and have the view below without having to click on both 2010/01/01 and 2010/02/02 ?
2010/01/01
2010/01/02
Thanks
Is there a possibility to collapse/expand a group level in radgridview UI ?
example: radgridview grouped by date
2010/01/01
row1
row2
row3
2010/01/02
row4
row5
row6
row7
I want to collapse the date group and have the view below without having to click on both 2010/01/01 and 2010/02/02 ?
2010/01/01
2010/01/02
Thanks
4 Answers, 1 is accepted
0
Hello Chris Thierry,
Kind regards,
Milan
the Telerik team
So far we have exposed two method that allow you to expand/collapse groups programmatically. The first one is called ExpandGroup and the second one is called CollapseGroup and they can be used as follows:
// to expand the second group
this
.gridView.ExpandGroup(
this
.gridView.Items.Groups[1]
as
IGroup);
// to collapse the first group
this
.gridView.CollapseGroup(
this
.gridView.Items.Groups[0]
as
IGroup);
To have the first two groups expanded you can subscribe to the Grouped event of RadGridView and use the ExpandGroup method:
void
gridView_Grouped(
object
sender, Telerik.Windows.Controls.GridViewGroupedEventArgs e)
{
// expand first two groups
this
.gridView.ExpandGroup(
this
.gridView.Items.Groups[0]
as
IGroup);
this
.gridView.ExpandGroup(
this
.gridView.Items.Groups[1]
as
IGroup);
}
Kind regards,
Milan
the Telerik team
Do you want to have your say when we set our development plans?
Do you want to know when a feature you care about is added or when a bug fixed?
Explore the
Telerik Public Issue Tracking
system and vote to affect the priority of the items
0
Gerald
Top achievements
Rank 1
answered on 31 Jan 2011, 06:40 PM
I tried subscribing to the "Grouped" event but it didn't fire when the grid was loaded. It only seems to fire when I manually add groups.
I have two groups that I add programatically and I would like them to be expanded by default. Is there any way to do this?
I have two groups that I add programatically and I would like them to be expanded by default. Is there any way to do this?
0
Hello Gerald,
Kind regards,
Milan
the Telerik team
The Grouped event would only be called if the operation is initiated from the UI. If you are adding the group descriptors before the grid is shown you can try the following approach.
public
MainPage()
{
InitializeComponent();
this
.playersGrid.GroupDescriptors.Add(
new
GroupDescriptor() { Member =
"Name"
});
this
.playersGrid.DataLoaded +=
new
EventHandler<EventArgs>(playersGrid_DataLoaded);
}
void
playersGrid_DataLoaded(
object
sender, EventArgs e)
{
if
(
this
.playersGrid.Items.Groups.Count > 0)
{
// expand first two groups
this
.playersGrid.ExpandGroup(
this
.playersGrid.Items.Groups[0]
as
IGroup);
this
.playersGrid.ExpandGroup(
this
.playersGrid.Items.Groups[1]
as
IGroup);
}
this
.playersGrid.DataLoaded -=
new
EventHandler<EventArgs>(playersGrid_DataLoaded);
}
If the descriptors are added after the grid is shown (on button click, for instance) you can simply use ExapndGroup right after the descriptors are added.
Hope this helps.
Kind regards,
Milan
the Telerik team
Let us know about your Windows Phone 7 application built with RadControls and we will help you promote it. Learn more>>
0
pat
Top achievements
Rank 1
answered on 20 Aug 2011, 12:00 AM
I am having problems with the selective grouping. If I check the number of groups using gridIn.GroupCount I get 3 which is what I would expect as I have added 3 groups programatically (gridIn.GroupDescriptors.Add(groupDesc)).
But when I try and collapse a group
gv.CollapseGroup(gv.Items.Groups[currentGoupingLevel] as IGroup);
It fails. If I check gv.Items.Groups.Count() it shows as 1 not three.
if I try
gv.CollapseGroup(gv.Items.Groups[0] as IGroup);
it simply collapses all 3 levels of detail.
What I am trying to do is have a button that collapses the grouping one group at a time.
Can you please tell me what I am missing and why gridIn.GroupCount shows as 3 but gv.Items.Groups.Count() shows as 1
Thanks,
PatC
But when I try and collapse a group
gv.CollapseGroup(gv.Items.Groups[currentGoupingLevel] as IGroup);
It fails. If I check gv.Items.Groups.Count() it shows as 1 not three.
if I try
gv.CollapseGroup(gv.Items.Groups[0] as IGroup);
it simply collapses all 3 levels of detail.
What I am trying to do is have a button that collapses the grouping one group at a time.
Can you please tell me what I am missing and why gridIn.GroupCount shows as 3 but gv.Items.Groups.Count() shows as 1
Thanks,
PatC