Hello,
Let me start with what my overall goal is, just in case I'm taking the completely wrong approach to this:
I have multiselect turned on on my RadGridView. I would like to allow a user to quickly select all the ChildRows of a group by just clicking on that specific GroupRow. I would also like to allow them to select multiple groups at the same time by holding shift or ctrl. This could be a combination of ChildRows and GroupRows.
Here's what I've tried doing:
1. Using the SelectionChanged event. When I select a GroupRow, the SelectedRows.Count property of my RadGridView is 0 (ie the IsSelected property of the GroupRow that I just selected is still false). I could use the CurrentRow property and just set all of the ChildRows of the current GroupRow to selected, but if the user holds down shift and selects many GroupRows at once, this will only catch the last one.
2. Using the CurrentRowChanged event. I'm not able to use this for the same reason as above: I can only select the ChildRows of the GroupRow that is last in the selection list.
3. Using the SelectionChanging event. Surprisingly, only a single row exists in e.Rows, despite me selecting multiple GroupRows.
So I'm left with CurrentRowChanging. With this event, I'm given the OldRow and the NewRow, so it is (probably) possible to determine if the user is holding down ctrl or shift, determine whether the user has filtered or sorted the rows, and then manually select each ChildRow under each GroupRow based on this logic, but that just seems a little obscure and unnecessary.
Here is my code (there's nothing to it)... I tried programatically selecting the 2nd group row as well, but the property will not set:
private
void
RadForm1_Load(
object
sender, EventArgs e)
{
DataTable dt =
new
DataTable();
dt.Columns.Add(
"col1"
,
typeof
(
string
));
dt.Columns.Add(
"col2"
,
typeof
(
int
));
dt.Rows.Add(
"group1"
, 0);
dt.Rows.Add(
"group1"
, 1);
dt.Rows.Add(
"group1"
, 2);
dt.Rows.Add(
"group1"
, 3);
dt.Rows.Add(
"group2"
, 0);
dt.Rows.Add(
"group2"
, 1);
dt.Rows.Add(
"group3"
, 0);
dt.Rows.Add(
"group3"
, 1);
dt.Rows.Add(
"group4"
, 0);
dt.Rows.Add(
"group5"
, 1);
dt.Rows.Add(
"group6"
, 0);
dt.Rows.Add(
"group7"
, 1);
radGridView1.DataSource = dt;
radGridView1.GroupDescriptors.Add(
new
Telerik.WinControls.UI.GridGroupByExpression(
"col1 GROUP BY col1"
));
radGridView1.Groups[1].GroupRow.IsSelected =
true
;
}
Thank you!