In my scenario, I'm supposed to attach a context menu on the rows of a raadgridview.
This context menu allows to perform various actions on the selected row.
But the thing is that my scenario include also the possibility of executing such action on multiple rows at once.
It was all working fine on the Q3 2009, but in Q1 2012, it seems that the multiple selection mechanism change.
I did some research and then set the SelectionMode to Extended, which gave me back the possibility of multiple selection on the grid, but when I right click to access the context menu, the grid unselect all rows except the one I used the right click on, which completely breaks my scenario.
How can I get this functionnality back ?
4 Answers, 1 is accepted
That is very strange. I tried to reproduce the problem but I could not. I am sending you a sample application which has a grid with extended selection and a RadContextMenu in use. Could you please run the application and try to reproduce the problem?
All the best,
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.
I tried modifying it to match my own and reproduce the issue, without success so far.
But my grid is really complex, it's hard to find out what's causing the problem.
But anyway, I still can't have a contextmenu on a multiple selection in my application.
A similar issue was reported by another customer and we were able to offer him a quick fix. In his solution some custom code was executed when RadContextMenu is opened:
private
void
RadContextMenu_Opened(
object
sender, RoutedEventArgs e)
{
RadContextMenu menu = (RadContextMenu)sender;
GridViewRow row = menu.GetClickedElement<GridViewRow>();
if
(row !=
null
)
{
if
(!RadGridView1.SelectedItems.Contains(row.Item))
RadGridView1.SelectedItems.Clear();
row.IsSelected = row.IsCurrent =
true
;
GridViewCell cell = menu.GetClickedElement<GridViewCell>();
if
(cell !=
null
)
{
cell.IsCurrent =
true
;
}
}
else
{
menu.IsOpen =
false
;
}
}
I am not sure you have such code in your application but in case you do you could try the following solutions:
By default RadGridView will sync its CurrentItem and SelectedItem. As a result whenever "row.IsSelected = row.IsCurrent = true;" is executed and the clicked item is not current , RadGridView will set it as current. Once a new CurrentItem is set the grid will try to sync SelectedItem - new SelectedItem will be set which ultimately deselects all other items.
There are two possible workarounds - the first one involves setting IsSynchronizedWithCurrentItem to false. With that setting set to false RadGridView will not try to sync SelectedItem when CurrentItem is changed and the selection will not be cleared.
The other approach is to remove the line which is changing the current item:
row.IsSelected = row.IsCurrent =
true
;
Hope this information will help you solve the problem.
All the best,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.
Thanks a lot.