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

RadGridView RowEditEnded How to get the old values

7 Answers 501 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Ravi
Top achievements
Rank 1
Ravi asked on 26 Apr 2011, 01:40 PM
Hi,

I am trying to edit the childgrid in the hierarchical grid, the row which  I am editting I want to compare the oldvalues and new values in the RowEditEnded event. How do i achieve this.

I have 3 columns in the childgrid. but in the oldvalues i have only count = 1 or which is the first column.

When i tried e.OldValues["firstcolumn"] = this is giving me the result.
When i tried e..OldValues["SecondColumn"] = this is throwing keynot found exception. likewise for the 3rd column.

Please advice.

Thanks

7 Answers, 1 is accepted

Sort by
0
Maya
Telerik team
answered on 26 Apr 2011, 02:45 PM
Hello David,

You may get an old value by using the UniqeName of the corresponding column. For example:

XAML:
<telerik:GridViewDataColumn DataMemberBinding="{Binding Name}"/>
 
C#:
private void clubsGrid_RowEditEnded(object sender, GridViewRowEditEndedEventArgs e)
        {
            var oldName = e.OldValues["Name"];
        }
 

Greetings,
Maya
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
Ravi
Top achievements
Rank 1
answered on 26 Apr 2011, 03:18 PM
Thanks for the update.

I have 3 columns in the row. When i try to get the OLD value of the second or third column its throwing an exception , key not found in the collection.

<telerikGridView:GridViewDataColumn Width="125">
                                <telerikGridView:GridViewDataColumn.Header>
                                    <TextBlock Text="Quantity"/>
                                </telerikGridView:GridViewDataColumn.Header>
                                <telerikGridView:GridViewDataColumn.CellTemplate>
                                    <DataTemplate>
                                        <TextBlock Text="{Binding Quantity}" Tag="{Binding}"/>
                                    </DataTemplate>
                                </telerikGridView:GridViewDataColumn.CellTemplate>
                                <telerikGridView:GridViewDataColumn.CellEditTemplate>
                                    <DataTemplate>
                                        <TextBox x:Name="txtQuantity" Text="{Binding Quantity, Mode=TwoWay}"></TextBox>
                                    </DataTemplate>
                                </telerikGridView:GridViewDataColumn.CellEditTemplate>
                            </telerikGridView:GridViewDataColumn>

Above is my second column, but i am not able to do as below
e.OldValues["Quantity"]

Please advice.

Thanks
0
Ravi
Top achievements
Rank 1
answered on 26 Apr 2011, 03:34 PM
I understand by using the DataMemberBinding attribute the column is visible in the OldValues, which is great. but i dont want the filter to appear on the column when i appy DataMemberBinding.

Please advice.

0
Accepted
Maya
Telerik team
answered on 26 Apr 2011, 03:38 PM
Hello David,

The OldValues can be appropriately used unless CellEditTemplate/CellTemplate are defined for the columns. So, what I would recommend you is to set the DataMemberBinding, remove the templates defined and set the IsFilterable property to "False":

<telerik:GridViewDataColumn DataMemberBinding="{Binding Name}" IsFilterable="False"/>
Thus you will be able to work with the OldValue, but still your column will not be filterable.
 

Greetings,
Maya
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
Jelena
Top achievements
Rank 1
answered on 23 Jul 2012, 03:08 PM
Hello,

What should we do if we have CellEditTemplate/CellTemplate? Is there a way to retrieve at least the name of the column(s) in which the change has occured?

Thanks,
Jelena
0
Maya
Telerik team
answered on 23 Jul 2012, 03:23 PM
Hi Jelena,

You can find the corresponding cell (through ParentOfType<T> extension method) and get its Column property. 

Kind regards,
Maya
the Telerik team

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

0
Jelena
Top achievements
Rank 1
answered on 23 Jul 2012, 03:35 PM
Nice. Thank you!

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