This is a migrated thread and some comments may be shown as answers.

Excel-like Cell, Row and Column Selection

14 Answers 319 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Uli
Top achievements
Rank 1
Uli asked on 29 Jul 2010, 11:26 AM
Hi everybody!

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

Sort by
0
Milan
Telerik team
answered on 29 Jul 2010, 12:16 PM
Hi Uli,

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
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
Uli
Top achievements
Rank 1
answered on 29 Jul 2010, 12:31 PM
Hi Milan,

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
0
Milan
Telerik team
answered on 29 Jul 2010, 04:47 PM
Hi 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
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
Uli
Top achievements
Rank 1
answered on 29 Jul 2010, 04:51 PM
Hi Milan,

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
0
Maya
Telerik team
answered on 03 Aug 2010, 12:29 PM
Hi 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.

 


All the best,
Maya
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
Kevin
Top achievements
Rank 1
answered on 27 Aug 2010, 08:11 PM
We really feel that the RadGrid really needs to support row header click events out of the box.  As well as the selection of rows when clicking on the header, but selection of cells via cell clicks, etc, once again, out of the box.

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!
0
Maya
Telerik team
answered on 30 Aug 2010, 11:50 AM
Hi Kevin,

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.
 

Sincerely yours,
Maya
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
Uli
Top achievements
Rank 1
answered on 01 Dec 2010, 02:50 PM
Do you know now when you will support combined row/cell selection?

Regards Uli
0
Maya
Telerik team
answered on 01 Dec 2010, 03:20 PM
Hello 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.
 

Best wishes,
Maya
the Telerik team
Browse the videos here>> to help you get started with RadControls for WPF
0
Alan
Top achievements
Rank 2
answered on 11 May 2011, 03:04 PM
This is a good solution for WPF, but it doesn't work Silverlight (no PreviewMouseLeftButtonDown). Do you have a solution for this to use in Silverlight? Thanks!
0
Maya
Telerik team
answered on 11 May 2011, 05:46 PM
Hello Alan,

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

Regards,
Maya
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
Alan
Top achievements
Rank 2
answered on 03 Dec 2012, 03:40 PM
The two lines below no longer work as of Q3 2012 SP1.

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.
0
Maya
Telerik team
answered on 03 Dec 2012, 03:47 PM
Hello Alan,

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".  

All the best,
Maya
the Telerik team

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

0
Alan
Top achievements
Rank 2
answered on 03 Dec 2012, 04:41 PM
Maya,

Great! Thank you.
Tags
GridView
Asked by
Uli
Top achievements
Rank 1
Answers by
Milan
Telerik team
Uli
Top achievements
Rank 1
Maya
Telerik team
Kevin
Top achievements
Rank 1
Alan
Top achievements
Rank 2
Share this question
or