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

GridView : "copy down" feature, a bit like in Excel

6 Answers 236 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Doots
Top achievements
Rank 1
Doots asked on 11 Jun 2012, 05:05 PM
Hi,

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

Sort by
0
Dimitrina
Telerik team
answered on 12 Jun 2012, 05:57 AM
Hi,

  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.

Greetings,
Didie
the Telerik team

Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

0
Doots
Top achievements
Rank 1
answered on 14 Jun 2012, 05:18 PM
Ok, thanks for your suggestions. As suggested I am using the Extended mode for selection and a context menu. I think it could match pretty well with the needs. 

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
0
Dimitrina
Telerik team
answered on 15 Jun 2012, 08:49 AM
Hi,

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

0
Doots
Top achievements
Rank 1
answered on 15 Jun 2012, 04:03 PM
Hi,

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
0
Accepted
Yana
Telerik team
answered on 20 Jun 2012, 10:32 AM
Hi Ronald,

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

0
Doots
Top achievements
Rank 1
answered on 04 Jul 2012, 08:45 AM
Hi Yana,

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

Regards,
Ronald
Tags
GridView
Asked by
Doots
Top achievements
Rank 1
Answers by
Dimitrina
Telerik team
Doots
Top achievements
Rank 1
Yana
Telerik team
Share this question
or