I have the need to lock a grouped column... in other words, to not allow the user to close (un-group) the selected column. Is this possible?
Take for instance grouping by the demo column "Title". I do not want to also then display the "Title" column seeing that it is now shown in the group. However, if you hid the "Title" column, and then programmatically group by that column... and then if the user closes that group - Oops! No "Title" column shown to re-group by later.
Thanks!
Take for instance grouping by the demo column "Title". I do not want to also then display the "Title" column seeing that it is now shown in the group. However, if you hid the "Title" column, and then programmatically group by that column... and then if the user closes that group - Oops! No "Title" column shown to re-group by later.
Thanks!
4 Answers, 1 is accepted
0
Accepted

Adam Marshall
Top achievements
Rank 1
answered on 01 Jul 2010, 09:35 PM
I needed the same functionality as you have mentioned too.
I used the "Grouping" event on the RadGridView and used the code behind to Cancel the close when it was clicked.
If there is a better way of doing this, I would love to know!
I used the "Grouping" event on the RadGridView and used the code behind to Cancel the close when it was clicked.
private void grid1_Grouping(object sender, GridViewGroupingEventArgs e) |
{ |
//cancel remove grouping on groupColumnName |
if (e.Action == System.ComponentModel.CollectionChangeAction.Remove && e.GroupDescriptor.DisplayContent.ToString() == "groupColumnName") |
{ |
e.Cancel = true; |
} |
} |
If there is a better way of doing this, I would love to know!
0

Mark
Top achievements
Rank 1
answered on 01 Jul 2010, 10:22 PM
Fantastic! That'll work... thanks for the help.
0

Adam Marshall
Top achievements
Rank 1
answered on 10 Nov 2010, 10:56 PM
This no longer works with the 2010 Q3 controls.
Modified code to cancel a "Grouping Close/Remove"
Modified code to cancel a "Grouping Close/Remove"
private void grid1_Grouping(object sender, GridViewGroupingEventArgs e)
{
//cancel remove grouping
if (e.Action == GroupingEventAction.Remove && ((Telerik.Windows.Data.GroupDescriptor)e.GroupDescriptor).Member == "YourGroupDescriptorMemberName")
{
e.Cancel = true;
}
}
0
Hello Adam,
Vanya Pavlova
the Telerik team
We introduced breaking changes in Q3 2010, please see them here.
Your code should look like this:
private
void
grid1_Grouping(
object
sender, GridViewGroupingEventArgs e)
{
//cancel remove grouping
if
(e.Action == GroupingEventAction.Remove &&
((e.GroupDescriptor
as
ColumnGroupDescriptor).Column
as
GridViewDataColumn).DataMemberBinding.Path.Path ==
"YourGroupDescriptorMemberName"
)
{
e.Cancel =
true
;
}
}
Hope this helps.
Best wishes,Vanya Pavlova
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