I would like to know if it's possible to create a "copy down" functionnality in GridView, a bit like in Excel.
The objective would be to enter values in some cells in the first rown of my grid, to select these cells, and with a contextual menu have a shortcut to "copy these values on every row of my grid".
The objective, is for users to type values only once instead of typing the same value on every row of the grid. I hope i'm clear enough in my explaination.
Thanks a lot for your help!
6 Answers, 1 is accepted
You could try to use Extended SelectionMode that will allow you to select multiple items by moving the mouse down. Once the cells are selected, you need to execute the copy-paste functionality in specific manner - by pressing a button for example or during an event. There is no such a built-in functionality though.
I hope this sheds some light in that matter.
Didie
the Telerik team
Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

I would like to know if it's possible to retrieve the selected cells values (and column names), and pass them to the view model using the click event of the context menu button ?
Thanks for your help!
Doots
You could get the clicked element using the GetClickedElement<element>() method of the RadContextMenu.
For example, you could get the clicked GridView like so:
private
void
RadContextMenu_ItemClicked(
object
sender, RoutedEventArgs e)
{
RadContextMenu menu = (RadContextMenu)sender;
RadGridView gridView = menu.GetClickedElement<RadGridView>();
// get the SelectedCells collection and insert your additional logic
}
Once you have it, you could access any information you need and use it accordingly.
You could as well take a look at our online demo showing row context menu.
All the best,
Didie
the Telerik team
Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

Thanks, I'm still having a problem with this solution. Here is my XAML :
<Telerik:RadGridView AutoGenerateColumns="False"
ItemsSource="{Binding SearchResultItems}"
x:Name="myGridView">
<telerik:RadContextMenu.ContextMenu>
<telerik:RadContextMenu x:Name="myCtxMenu">
<telerik:RadMenuItem Header="Test button" >
<i:Interaction.Triggers>
<i:EventTrigger EventName="Click">
<commands:EventToCommand Command="{Binding TestCommand}" CommandParameter="{Binding SelectedCells, ElementName=myGridView}" />
</i:EventTrigger>
</i:Interaction.Triggers>
</telerik:RadMenuItem>
</telerik:RadContextMenu>
</telerik:RadContextMenu.ContextMenu>
<telerik:RadGridView.Columns>
<telerik:GridViewDataColumn DataMemberBinding="{Binding FieldOne}" Header="Header 1" Width="200" />
<telerik:GridViewDataColumn DataMemberBinding="{Binding FieldTwo}" Header="Header 2" Width="200" />
</telerik:RadGridView.Columns>
</Telerik:RadGridView>
I select some cells but the parameter SelectedCells is null when the event is fired and catched in my ViewModel. The problem is the same if I use other parameters. The three following commands still send a null parameter to my ViewModel, so I'm not able to retrieve the sender or the parameters.
<commands:EventToCommand Command="{Binding TestCommand}" CommandParameter="{Binding SelectedCells, ElementName=myGridView}" />
<commands:EventToCommand Command="{Binding TestCommand}" CommandParameter="{Binding SelectedItems, ElementName=myGridView}" />
<commands:EventToCommand Command="{Binding TestCommand}" CommandParameter="{Binding ElementName=myGridView}" />
Do you know why ? Thanks for your help!
Doots
I've attached an example which demonstrates the recommended way to use RadContextMenu in MVVM scenarios. The approach is based on the following Code Library project:
http://www.telerik.com/support/kb/wpf/contextmenu/radcontextmenu-mvvm.aspx
Please download the example and give it a try.
All the best,
Yana
the Telerik team
Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

Thanks for your help, your solution works as I want :)
Regards,
Ronald