Hi All,
Our application contains a grid that allows grouping and multi select. Upon entering the screen the groups are collapsed. Our client wants to be able to select on or more groups and all it's child records by clicking on the group(s) without expanding them.
I achieved this behaviour via the following event handlers:
The first event is used to change the row color of a group in case one of its child records is selected:
the second event i use to select all child rows in case a group was selected (this currently works only in case of on level of grouping) and i always invalidate all rows to make sure that the formatting event is triggered for all groups (for instance a child row is selected i want the color of the group to change aswell)
The problem however with this approach is that the shift option for multi select is not supported. A user can now select multiple groups with the ctrl button but not with the shift button. Somebody any idea? Other ideas to implement such a behaviour?
Many thanks!
Maarten
Our application contains a grid that allows grouping and multi select. Upon entering the screen the groups are collapsed. Our client wants to be able to select on or more groups and all it's child records by clicking on the group(s) without expanding them.
I achieved this behaviour via the following event handlers:
SelectionResultRadGridView.ViewRowFormatting += SelectionResultRadGridViewViewRowFormatting;
SelectionResultRadGridView.CellClick += SelectionResultRadGridViewCellClick;
The first event is used to change the row color of a group in case one of its child records is selected:
private static void SelectionResultRadGridViewViewRowFormatting(object sender, RowFormattingEventArgs e)
{
if (e.RowElement.RowInfo is GridViewGroupRowInfo && e.RowElement.RowInfo.ChildRows.Any(x => x.IsSelected))
{
e.RowElement.DrawFill = true;
e.RowElement.BackColor = Color.FromArgb(255,216,132);
e.RowElement.GradientStyle = GradientStyles.Solid;
}
else
{
e.RowElement.ResetValue(LightVisualElement.DrawFillProperty, ValueResetFlags.Local);
e.RowElement.ResetValue(LightVisualElement.BackColorProperty, ValueResetFlags.Local);
e.RowElement.ResetValue(LightVisualElement.NumberOfColorsProperty, ValueResetFlags.Local);
e.RowElement.ResetValue(LightVisualElement.ForeColorProperty, ValueResetFlags.Local);
}
}
the second event i use to select all child rows in case a group was selected (this currently works only in case of on level of grouping) and i always invalidate all rows to make sure that the formatting event is triggered for all groups (for instance a child row is selected i want the color of the group to change aswell)
void SelectionResultRadGridViewCellClick(object sender, GridViewCellEventArgs e)
{
if (e.Row.RowElementType == typeof(GridGroupHeaderRowElement))
{
foreach (var childRow in e.Row.ChildRows)
{
childRow.IsSelected = true;
}
}
foreach (DataGroup group in SelectionResultRadGridView.Groups)
{
group.GroupRow.InvalidateRow();
}
}
The problem however with this approach is that the shift option for multi select is not supported. A user can now select multiple groups with the ctrl button but not with the shift button. Somebody any idea? Other ideas to implement such a behaviour?
Many thanks!
Maarten