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
Thanks
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
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.
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
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.
Nedyalko Nikolov
the Telerik team
That's how I went about it eventually.
"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
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>();
Kind regards,
Nedyalko Nikolov
the Telerik team
Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get now >>