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

DragAndDrop a Row between RadGridView

3 Answers 39 Views
DragAndDrop
This is a migrated thread and some comments may be shown as answers.
Shishir
Top achievements
Rank 1
Shishir asked on 13 Aug 2014, 02:55 PM
I searched over the net and I could not find any easy way to Drag and drop a row between 2 dynamically created RadGridView. Can you please suggest a way for doing this.

3 Answers, 1 is accepted

Sort by
0
Accepted
Dimitrina
Telerik team
answered on 14 Aug 2014, 06:51 AM
Hi,

I attached a sample project.
As an additional example, you can check how the GridViewDragDropBehavior is implemented in our "Reorder Rows" and "Tree to Grid Drag" WPF Demos. The second one illustrates how to drag and drop between different controls.

Regards,
Didie
Telerik
 
Check out Telerik Analytics, the service which allows developers to discover app usage patterns, analyze user data, log exceptions, solve problems and profile application performance at run time. Watch the videos and start improving your app based on facts, not hunches.
 
0
Shishir
Top achievements
Rank 1
answered on 14 Aug 2014, 08:14 AM
My Requirement is this. I have a RadListBox which contains an ItemTemplate consisting of a RadGridView. This RadGridView is inside an Expander. I have attached a xaml below. The requrement is, I should be able to Re-Order the ListBoxItems through DragAndDrop and move the Rows between the RadGridViews. The RadGridViews are created dynamically and there can be a maximum of 50 RadGridViews. I have also attached a screenshot of the UI to make the things more clearer.

The Xaml looks as shown below,
 <telerik:RadListBox Grid.Row="1"
                            Name="GroupsListBox"
                 Margin="10,10,10,10"
                 ItemsSource="{Binding Path=Groups, Mode=TwoWay}"
                 SelectedItem="{Binding Path=SelectedGroup, Mode=TwoWay}"
                 AllowDrop="True">        

            <telerik:RadListBox.ItemTemplate>
                <DataTemplate>
                    <Expander Name="GroupsExpander">
                        <Expander.Header>
                            <Border Background="LightGray">
                                <TextBlock Foreground="Black" FontWeight="Bold" FontSize="14" Text="{Binding Path=Name, Mode=OneWay}"
                                           Width="{Binding ElementName=GroupsExpander, Path=ActualWidth}"
                                           HorizontalAlignment="Stretch" />
                             </Border>
                        </Expander.Header>
                        <StackPanel>
                            <telerik:RadGridView AutoGenerateColumns="False" 
                                             ShowGroupPanel="false" 
                                             CanUserResizeColumns="False" 
                                             CanUserResizeRows="False" 
                                             CanUserReorderColumns="False" 
                                             CanUserInsertRows="True"
                                             CanUserFreezeColumns="True" 
                                             CanUserSortColumns="False" 
                                             IsFilteringAllowed="False"
                                             HorizontalAlignment="Stretch" 
                                             SelectedItem="{Binding Path=DataContext.SelectedRow, 
                                                            RelativeSource={RelativeSource AncestorType={x:Type local:PriceDeckSettingsTabView}}, 
                                                            Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
                                             ClipboardPasteMode="None" 
                                             CellValidating="gridMain_CellValidating" 
                                             RowEditEnded="gridMain_RowEditEnded" 
                                             SelectionChanged="gridMain_SelectionChanged"
                                             Margin="10">
                                
                                <telerik:RadGridView.ItemsSource>
                                    <MultiBinding Converter="{StaticResource ResourceKey=PriceGroupSelectionConverter}" Mode="OneWay">
                                        <Binding Source="{StaticResource ResourceKey=GroupedPricesSource}" Mode="OneWay"/>
                                        <Binding Mode="OneTime"/>
                                    </MultiBinding>
                                </telerik:RadGridView.ItemsSource>

                                <telerik:RadGridView.Columns>

                                    <telerik:GridViewDataColumn DataMemberBinding="{Binding Name, Mode=TwoWay}" IsReadOnly="False" IsFilterable="False" IsGroupable="False" IsReorderable="False" IsSortable="True"
                                                                Header="{localization:Resx ResxName=Palantir.CorporateAssumptions.Price.Presentation.Properties.Resources, Key=ColumnHeader_PriceName}"
                                                                HeaderTextAlignment="Center" Width="150">

                                        <telerik:GridViewDataColumn.CellTemplate>
                                            <DataTemplate>
                                                <TextBlock Text = "{Binding Path=Name, Mode=TwoWay, ValidatesOnDataErrors=True, UpdateSourceTrigger=PropertyChanged}"
                                                Validation.ErrorTemplate ="{StaticResource ResourceKey=errorTemplate}"/>
                                            </DataTemplate>
                                        </telerik:GridViewDataColumn.CellTemplate>
                                    </telerik:GridViewDataColumn>

                                    <telerik:GridViewDataColumn DataMemberBinding="{Binding PriceType, Mode=TwoWay}"
                                                                Header="{localization:Resx ResxName=Palantir.CorporateAssumptions.Price.Presentation.Properties.Resources, Key=ColumnHeader_PriceType}"
                                                                HeaderTextAlignment="Center" IsFilterable="False" IsGroupable="True"  Width="150">

                                        <telerik:GridViewDataColumn.CellEditTemplate>
                                            <DataTemplate>
                                                <telerik:RadComboBox SelectedItem="{Binding Path=PriceType, Mode=TwoWay}">
                                                    <telerik:RadComboBox.ItemsSource>
                                                        <Binding Path="PriceTypes"/>
                                                    </telerik:RadComboBox.ItemsSource>
                                                </telerik:RadComboBox>
                                            </DataTemplate>
                                        </telerik:GridViewDataColumn.CellEditTemplate>
                                        <telerik:GridViewDataColumn.CellTemplate>
                                            <DataTemplate>
                                                <TextBlock Text="{Binding PriceType, Converter={StaticResource ResourceKey=enumDescriptionConverter}}"/>
                                            </DataTemplate>
                                        </telerik:GridViewDataColumn.CellTemplate>

                                    </telerik:GridViewDataColumn>

                                    <telerik:GridViewDataColumn DataMemberBinding="{Binding MeasurementType, Mode=TwoWay}" IsReadOnly="False" 
                                                                Header="{localization:Resx ResxName=Palantir.CorporateAssumptions.Price.Presentation.Properties.Resources, Key=ColumnHeader_PriceMeasurementType}"
                                                                HeaderTextAlignment="Center" Width="150">

                                        <telerik:GridViewDataColumn.CellEditTemplate>
                                            <DataTemplate>
                                                <telerik:RadComboBox SelectedItem="{Binding Path=MeasurementType, Mode=TwoWay}">
                                                    <telerik:RadComboBox.ItemsSource>
                                                        <Binding Path="MeasurementTypes"/>
                                                    </telerik:RadComboBox.ItemsSource>
                                                </telerik:RadComboBox>
                                            </DataTemplate>
                                        </telerik:GridViewDataColumn.CellEditTemplate>
                                        <telerik:GridViewDataColumn.CellTemplate>
                                            <DataTemplate>
                                                <TextBlock Text="{Binding MeasurementType, Converter={StaticResource ResourceKey=enumDescriptionConverter}}"/>
                                            </DataTemplate>
                                        </telerik:GridViewDataColumn.CellTemplate>

                                    </telerik:GridViewDataColumn>

                                    <telerik:GridViewDataColumn DataMemberBinding="{Binding Currency, Mode=TwoWay}" IsReadOnly="False" 
                                                                Header="{localization:Resx ResxName=Palantir.CorporateAssumptions.Price.Presentation.Properties.Resources, Key=ColumnHeader_PriceCurrency}"
                                                                HeaderTextAlignment="Center" Width="175">

                                        <telerik:GridViewDataColumn.CellEditTemplate>
                                            <DataTemplate>
                                                <telerik:RadComboBox SelectedItem="{Binding Path=Currency, Mode=TwoWay}">
                                                    <telerik:RadComboBox.ItemsSource>
                                                        <Binding Path="Currencies"/>
                                                    </telerik:RadComboBox.ItemsSource>
                                                </telerik:RadComboBox>
                                            </DataTemplate>
                                        </telerik:GridViewDataColumn.CellEditTemplate>
                                        <telerik:GridViewDataColumn.CellTemplate>
                                            <DataTemplate>
                                                <TextBlock Text="{Binding Currency, Converter={StaticResource ResourceKey=enumDescriptionConverter}}"/>
                                            </DataTemplate>
                                        </telerik:GridViewDataColumn.CellTemplate>

                                    </telerik:GridViewDataColumn>

                                    <telerik:GridViewDataColumn DataMemberBinding="{Binding RealNominalOption, Mode=TwoWay}" IsReadOnly="False" 
                                                                Header="{localization:Resx ResxName=Palantir.CorporateAssumptions.Price.Presentation.Properties.Resources, Key=ColumnHeader_PriceRealNominal}"
                                                                HeaderTextAlignment="Center" Width="150">

                                        <telerik:GridViewDataColumn.CellEditTemplate>
                                            <DataTemplate>
                                                <telerik:RadComboBox SelectedItem="{Binding Path=RealNominalOption, Mode=TwoWay}">
                                                    <telerik:RadComboBox.ItemsSource>
                                                        <Binding Path="RealAndNominal"/>
                                                    </telerik:RadComboBox.ItemsSource>
                                                </telerik:RadComboBox>
                                            </DataTemplate>
                                        </telerik:GridViewDataColumn.CellEditTemplate>
                                        <telerik:GridViewDataColumn.CellTemplate>
                                            <DataTemplate>
                                                <TextBlock Text="{Binding RealNominalOption, Converter={StaticResource ResourceKey=enumDescriptionConverter}}"/>
                                            </DataTemplate>
                                        </telerik:GridViewDataColumn.CellTemplate>

                                    </telerik:GridViewDataColumn>

                                    <telerik:GridViewDataColumn DataMemberBinding="{Binding UnitType, Mode=TwoWay}" IsReadOnly="False" 
                                                                Header="{localization:Resx ResxName=Palantir.CorporateAssumptions.Price.Presentation.Properties.Resources, Key=ColumnHeader_PriceUnitType}"
                                                                HeaderTextAlignment="Center" Width="150">

                                        <telerik:GridViewDataColumn.CellEditTemplate>
                                            <DataTemplate>
                                                <telerik:RadComboBox SelectedItem="{Binding Path=UnitType, Mode=TwoWay}">
                                                    <telerik:RadComboBox.ItemsSource>
                                                        <Binding Path="UnitTypes"/>
                                                    </telerik:RadComboBox.ItemsSource>
                                                </telerik:RadComboBox>
                                            </DataTemplate>
                                        </telerik:GridViewDataColumn.CellEditTemplate>
                                        <telerik:GridViewDataColumn.CellTemplate>
                                            <DataTemplate>
                                                <TextBlock Text="{Binding UnitType, Converter={StaticResource ResourceKey=enumDescriptionConverter}}"/>
                                            </DataTemplate>
                                        </telerik:GridViewDataColumn.CellTemplate>

                                    </telerik:GridViewDataColumn>

                                    <telerik:GridViewDataColumn DataMemberBinding="{Binding PriceUnit, Mode=TwoWay}"  
                                                                Header="{localization:Resx ResxName=Palantir.CorporateAssumptions.Price.Presentation.Properties.Resources, Key=ColumnHeader_Units}"
                                                                HeaderTextAlignment="Center" Width="150" IsReadOnly="True">
                    
                                        <telerik:GridViewDataColumn.CellTemplate>
                                            <DataTemplate>
                                                <TextBlock Text="{Binding PriceUnit, Mode=OneWay}"/>
                                            </DataTemplate>
                                        </telerik:GridViewDataColumn.CellTemplate>

                                    </telerik:GridViewDataColumn>

                                </telerik:RadGridView.Columns>
                                
                            </telerik:RadGridView>
                        </StackPanel>
                    </Expander>
                </DataTemplate>
            </telerik:RadListBox.ItemTemplate>
        </telerik:RadListBox>
0
Dimitrina
Telerik team
answered on 15 Aug 2014, 10:42 AM
Hi,

You can also refer to the DragDropManager online documentation. Let me know in case you meet any specific problem implementing your requirement.

Regards,
Didie
Telerik
 
Check out Telerik Analytics, the service which allows developers to discover app usage patterns, analyze user data, log exceptions, solve problems and profile application performance at run time. Watch the videos and start improving your app based on facts, not hunches.
 
Tags
DragAndDrop
Asked by
Shishir
Top achievements
Rank 1
Answers by
Dimitrina
Telerik team
Shishir
Top achievements
Rank 1
Share this question
or