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

Problem pasting multiple rows in grid view

5 Answers 313 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Ricardo
Top achievements
Rank 1
Ricardo asked on 04 Jul 2012, 02:30 PM
Hi,

I have a problem using "paste" in radgridView of 2012.2.607.40. (it Works well of 2011.3.1116.40).

I select 3 rows in Excel,copy them and I want to paste these in  my grid.  I click new row then click paste. I hope that the 3 rows will in the last 3 rows in my grid. it means that these 3 rows will be 3 new rows of my grid. BUT the result is , it will erase the first 3 rows of my current grid. Sometimes il will erasing the last few rows.

For exemple : I have 1,2,3,4 in my grid, each number in a different row (4 rows). Now, i want to paste 5,6,7 in the grid, I click add rows (now I have 1,2,3,4,0 in 5 rows), and click paste, the result that I want is 1,2,3,4,5,6,7, BUT the result is 5,6,7,4,0 .

Here is my grid :   
           <telerik:RadGridView
                SelectionMode="Extended" MaxHeight="150" x:Name="gridView"
                IsReadOnly="{Binding Path=ObjectBase.IsReadOnly, RelativeSource={RelativeSource FindAncestor, AncestorType=sc:GridDesigner}}"
                VerticalAlignment="Top" CanUserDeleteRows="True" RowIndicatorVisibility="Visible"
                CanUserFreezeColumns="False" CanUserInsertRows="True" ShowGroupPanel="False"
                AutoGenerateColumns="True" CanUserSelect="True" SelectionUnit="FullRow"
                ClipboardCopyMode="Cells" ClipboardPasteMode="Default" BorderThickness="0" EnableRowVirtualization="True">
            </telerik:RadGridView>

Then I have tried to use the control of Pasting like this :
private void gridView_Pasting(object sender, GridViewClipboardEventArgs e)
{
    var newItem = this.radGridView1.Items.AddNew();
    this.gridView.SelectedItem = newItem;
}

And also like this:

        private void gridView_Pasting(object sender, Telerik.Windows.Controls.GridViewClipboardEventArgs e)
        {
            this.gridView.Items.MoveCurrentToLast();
        }

but it doesn't work.

Thank you in advance for your help.

Ricardo Chorro.

5 Answers, 1 is accepted

Sort by
0
Maya
Telerik team
answered on 06 Jul 2012, 06:37 AM
Hi Ricardo,

Indeed, that would be the expected behavior. What you can try is to handle Pasting event, cancel it and add the items you have just copied explicitly in the source of the grid. 

All the best,
Maya
the Telerik team

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

0
Ankur
Top achievements
Rank 1
answered on 30 Oct 2012, 05:10 PM
Hi Ricardo,

I am facing the same problem. Did you manage to resolve it?

Thanks in advance.

Ankur
0
Maya
Telerik team
answered on 31 Oct 2012, 04:07 PM
Hello Ankur,

Did you try the approach suggested above ?  

All the best,
Maya
the Telerik team

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

0
Ankur
Top achievements
Rank 1
answered on 31 Oct 2012, 04:22 PM
Thanks Maya for your reply.

Can you point me to a link on how to implement it? I have just started using Telerik controls for the first time so still in the learning phase...
0
Maya
Telerik team
answered on 01 Nov 2012, 09:38 AM
Hi Ankur,

Firstly, you need to add handler for the Pasting event of RadGridView and get the text being copied from the Clipboard. Check out this article for more information. Once you get the values, you can create new business object, assign the values and add it to the source of the grid (you can get the source from the ItemsSource of the grid or from its Items collection).

Kind regards,
Maya
the Telerik team

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

Tags
GridView
Asked by
Ricardo
Top achievements
Rank 1
Answers by
Maya
Telerik team
Ankur
Top achievements
Rank 1
Share this question
or