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

[Solved] RadGridView simple row cut and paste

5 Answers 233 Views
GridView
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Jim
Top achievements
Rank 1
Jim asked on 28 Jul 2011, 04:08 PM
I have a grid with

 

 

SelectionMode="Single"

 

 

 

SelectionUnit="FullRow"

 

 

I select the grid row ( on the row column bar on the left ) and the row highlights and I press Cntl C
I then click for a new row
I then select the NEW grid row ( on the row column bar on the left ) and the NEW row highlights and I press Cntl V
But nothing gets pasted ?
At the moment I only want to cut/paste within the same grid, but evemtually I will need ..
1) Cut/Past to from Excel.and the same grid.
2) A right mouse context menu ( which I have ) but don't know how to make is cut/paste

Guidance please ...
Thanks
Jim

5 Answers, 1 is accepted

Sort by
0
Maya
Telerik team
answered on 28 Jul 2011, 04:27 PM
Hi Jim,

Generally, there should be problem to perform the actions you require. I have tested the case on this demo. Once I select an item, copy it (with Cntr + C), select another item and pasted the copied values (Cntr + P), the newly selected item is updated with those copied values.
May you take a look at the example and let me know whether you can get the same behavior there ?  

Kind regards,
Maya
the Telerik team

Register for the Q2 2011 What's New Webinar Week. Mark your calendar for the week starting July 18th and book your seat for a walk through of all the exciting stuff we will ship with the new release!

0
Jim
Top achievements
Rank 1
answered on 29 Jul 2011, 08:36 AM

After your reply I implemented a very simple grid and yes Cntrl C and Cntrl V do copy/paste rows.
So I then set about adding bits from my grid to the simple grid till it didn't work.
After some time I discovered it was having INotifyPropertyChanged on the Data class
Suggestions please ( See code below )

<telerik:RadGridView  Name="RadGridView1"           
            ItemsSource="{Binding}">
</telerik:RadGridView>
Dim p As ObservableCollection(Of Person)
 p = New ObservableCollection(Of Person)
 p.Add(New Person("Jimmy", "57"))
 p.Add(New Person("Alan", "28"))
 p.Add(New Person("Fred", "101"))
 DataContext = p

This works OK
Public Class Person
    Public Property name As String
    Public Property age As String
    Public Sub New(n As String, a As String)
        name = n
        age = a
    End Sub
End Class

This does not work ?
Public Class Person
    Implements INotifyPropertyChanged
    Public Event PropertyChanged As PropertyChangedEventHandler _
      Implements INotifyPropertyChanged.PropertyChanged
    Private Sub NotifyPropertyChanged(ByVal info As String)
        RaiseEvent PropertyChanged(Me, New PropertyChangedEventArgs(info))
    End Sub
    Public Property name As String
    Public Property age As String
    Public Sub New(n As String, a As String)
        name = n
        age = a
    End Sub
End Class
0
Jim
Top achievements
Rank 1
answered on 29 Jul 2011, 09:13 AM
Hmm , most strange.
When I paste into a new row ( or existing row ) it "apparantly" doesn't work.
However the data is in the row and if I click a cell that cells data appears.
Also if I save the grid and reload ithe new row appears.
So its somthing to do with updating the view I think ???
Any ideas
Jim
0
Yavor Georgiev
Telerik team
answered on 29 Jul 2011, 12:12 PM
Hi Jim,

 You need to raise the PropertyChanged event on the Person class every time you set a property. When pasting, RadGridView checks if the data item implements INotifyPropertyChanged. If it doesn't, it refreshes its view manually. However, there is a small performance penalty when doing this, so if the data item does implement INotifyPropertyChanged, RadGridView relies on the data item to raise the PropertyChanged event and trigger the built-in Silverlight binding update.

 In your case, your Person class implements INotifyPropertyChanged, but does not raise PropertyChanged when its properties are set. If you modify the properties to raise the event when they are set, RadGridView should update the UI normally on pasting.

Regards, Yavor Georgiev
the Telerik team

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

0
Jim
Top achievements
Rank 1
answered on 29 Jul 2011, 01:13 PM
OK I took them out of my classes and things Works OK
The grid still seems to update the collection.
Thanks
Jim
Tags
GridView
Asked by
Jim
Top achievements
Rank 1
Answers by
Maya
Telerik team
Jim
Top achievements
Rank 1
Yavor Georgiev
Telerik team
Share this question
or