I want to provide the possibility to select multiple rows, columns and cells like in Excel. That means I need a combination of row and cell selection. Are there any demos are examples how to achieve this?
If I have to implement it myself, an event that is fired when a row or column header cell is clicked would be helpful. Does it exist?
Thanks
Uli
14 Answers, 1 is accepted
Currently you can only select cells or rows - mix mode is not available but we will introduce it in a future release.
In regards to the selection events, RadGridView has two events that notify when selection has changed: SelectionChanged which occurs when items are selected or unselected and SelectedCellsChanged when occurs when cells are selected or unselected.
Sincerely yours,Milan
the Telerik team

thanks for your quick reply.
I think the selection events are not useful to me. I am planning to switch between cell selection and row selection when the user clicks into a row header cell. Therefore I need to get informed about this. Is there an event that just signals that the user clicked into a row header cell?
Regards
Uli
RadGridView has not built-in event that is fired when a header cell is clicked but you could easily subscribe to the MouseLeftButtonUp event of those cells. There is a possible caveat though - when you switch to row selection all selected cells will be cleared and I am not sure if this behavior is desired. Similarly, all selected items will be cleared when you switch from row selection to cell selection.
If you believe that such problems will not pose a problem to your project we could send you a sample project.
Best wishes,
Milan
the Telerik team

it would be great if you could send me a such a sample project. The restrictions you mentioned are no problem for me.
Thanks
Uli
There are a couple of steps you need to follow in order to accomplish the goal of changing the Selection Unit from row to cell:
1. You need to find the IndicatorPresenter (the row header) and handle its event MouseLeftButtonDown:
private void playersGrid_RowLoaded(object sender, RowLoadedEventArgs e)
{
GridViewRow row = e.Row as GridViewRow;
if (row != null)
{
Border indicatorPresenter = row.ChildrenOfType<
Border
>().Where(b => b.Name == "PART_IndicatorPresenter").FirstOrDefault();
indicatorPresenter.MouseLeftButtonDown += new MouseButtonEventHandler(indicatorPresenter_MouseLeftButtonDown);
}
}
2. Set the Property of the grid SelectionUnit to "FullRow" during that event:
void indicatorPresenter_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
{
this.playersGrid.SelectionUnit = GridViewSelectionUnit.FullRow;
}
3. Handle the PreviewMouseLeftButtonDown event on the grid so that you can change the Selection Unit to "cell" when clicking on a cell:
void playersGrid_PreviewMouseLeftButtonDown(object sender, MouseButtonEventArgs e)
{
var element = e.OriginalSource as FrameworkElement;
var cell = element.ParentOfType<
GridViewCell
>();
if (cell != null)
{
this.playersGrid.SelectionUnit = GridViewSelectionUnit.Cell;
}
}
I am sending you the sample project so that you can use it as a reference.
Maya
the Telerik team

Cell selection improved by leaps and bounds with click and drag, but these last few selection issues are critical to meet our customer's expectations.
Thanks!
We do consider to enable the functionality of cell/row selection depending on the element you are clicking on. However, we are still in the process of its most appropriate implementation and we cannot define a precise time frame for its completion.
As for the cell selection improvement by leaps and bounds, please provide more details about your exact expectations so that we could consider your proper requirements.
Maya
the Telerik team

Regards Uli
Unfortunately, we still cannot specify any time frame for the implementation of this functionality. However, it has been logged into our Public Issue Tracking System and you may track its progress here. As we aim at meeting the requirements of as more of our customers as possible, we do take into account the rating of a particular issue and prioritize it. Consequently, I would encourage you to vote for this particular one so that its rating gets higher and we concentrate our attention on it.
Maya
the Telerik team

You may take a look at this forum thread demonstrating the implementation, but targeting Silverlight platform.
Maya
the Telerik team

Border indicatorPresenter = row.ChildrenOfType<Border>().Where(b => b.Name ==
"PART_IndicatorPresenter"
).FirstOrDefault();
indicatorPresenter.MouseLeftButtonDown +=
new
MouseButtonEventHandler(indicatorPresenter_MouseLeftButtonDown);
indicatorPresenter is NULL.
Do you have any modifications to this example that will work with Q3 2012 SP1?
Thanks.
We have introduced such feature out-of-the-box with our current official release Q3 2012 SP1. All you need to do is set SelectionUnit property of the grid to "Mixed".
Maya
the Telerik team
Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

Great! Thank you.