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

OldValues.Count 0 on edited row after an insert

8 Answers 25 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Courouble Damien
Top achievements
Rank 1
Courouble Damien asked on 05 Oct 2010, 12:58 PM
Hi everyone, 

I'm working on a grid, my issue is the following

1) I add a new row with begin insert stuff,
2) When the row is editedend, i save it to Database
3) When i want to edited the row right after the insert, i go back in the editedend event but the OldValues in gridviewroweditendedeventArgs doesn't have element

It's really annoying, because i need to compare the oldvalues (the one right after the insert) and the newones ( the one we juste set up on edited) to proceed of certain query in DB

Do you know when i can store this informations  ? 

I hope i was clear,

Thanks

8 Answers, 1 is accepted

Sort by
0
Courouble Damien
Top achievements
Rank 1
answered on 07 Oct 2010, 10:12 AM
Someone to help me ? 

Thanks
0
Nedyalko Nikolov
Telerik team
answered on 07 Oct 2010, 01:57 PM
Hello Courouble Damien,

The "OldValues" dictionary is created when any cell of the row enters into edit mode. Do you use CellTemplates to edit underlying properties?

All the best,
Nedyalko Nikolov
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Courouble Damien
Top achievements
Rank 1
answered on 12 Oct 2010, 10:36 AM
Hey,

Nevermind i found a new way to do things, i wasn't using celltemplate, but the issue come from the fact that i was binding a silverlight datatable

Thanks,

D.
0
Alex Galie
Top achievements
Rank 2
answered on 20 May 2011, 04:48 PM
Hello,

Digging up this old thread because I'm running into the same issue. I AM using cell edit templates, just curious if there's a way to retain the old values even so.

Here's a portion of XAML:

<telerik:GridViewDataColumn Header="Asset"
                            DataMemberBinding="{Binding Name}" />
 
<telerik:GridViewDataColumn Header="Site" UniqueName="SiteColumn"
                            DataMemberBinding="{Binding Converter={StaticResource MapObjectLocationConverter}, ConverterParameter=Site}">
    <telerik:GridViewDataColumn.CellEditTemplate>
        <DataTemplate>
            <telerik:RadComboBox x:Name="SiteList" IsEditable="True" DisplayMemberPath="Name"
                                 ItemsSource="{Binding Company.Locations}"
                                 SelectedItem="{Binding Site, Mode=TwoWay}" />
        </DataTemplate>
    </telerik:GridViewDataColumn.CellEditTemplate>
</telerik:GridViewDataColumn>

The Asset column is added to the OldValues, but the 2nd one does not.

Thanks
0
Nedyalko Nikolov
Telerik team
answered on 25 May 2011, 02:33 PM
Hello Alex Galie,

Generally OldValues are generated based on column's data member binding via reflection, and for this column we cannot get any value for this column, so we cannot add anything in OldValues dictionary.

However you can use RadGridView's support for IEditableObject interface to achieve your scenario - at BeginEdit() - take the old values and at EndEdit() compare them with new ones.
Let me know if there is something unclear. 

Regards,
Nedyalko Nikolov
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Alex Galie
Top achievements
Rank 2
answered on 25 May 2011, 02:46 PM
Thanks,

That's how I went about it eventually.
0
Eric
Top achievements
Rank 1
answered on 03 Aug 2011, 12:07 AM
In regards to your solution of grabbing OldValues on begin edit and comparing them on EndEdit.

"However you can use RadGridView's support for IEditableObject interface to achieve your scenario - at BeginEdit() - take the old values and at EndEdit() compare them with new ones.
Let me know if there is something unclear. "

Can you provide a code sample for this. I am running into the same issue. I have a checkbox that is part of a CellTemplate. I need to inspect the value of the checkbox to see if it changed also.

Thanks,
Eric
0
Nedyalko Nikolov
Telerik team
answered on 05 Aug 2011, 01:00 PM
Hi Eric,

Your business object (DataContext of the GridViewRow) should implement IEditableObject interface which exposes BeginEdit(), EndEdit() and CancelEdit() methods.

public class Person : IEditableObject
{
#region IEditableObject Members
 
        public void BeginEdit()
        {
            throw new NotImplementedException();
        }
 
        public void CancelEdit()
        {
            throw new NotImplementedException();
        }
 
        public void EndEdit()
        {
            throw new NotImplementedException();
        }
 
        #endregion
}
 
this.radGridView.ItemsSource = new ObservableCollection<Person>();

Let me know if you need further assistance.

Kind regards,
Nedyalko Nikolov
the Telerik team

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

Tags
GridView
Asked by
Courouble Damien
Top achievements
Rank 1
Answers by
Courouble Damien
Top achievements
Rank 1
Nedyalko Nikolov
Telerik team
Alex Galie
Top achievements
Rank 2
Eric
Top achievements
Rank 1
Share this question
or