RadGridView RowEditEnded How to get the old values

8 posts, 1 answers
  1. Ravi
    Ravi avatar
    104 posts
    Member since:
    Oct 2012

    Posted 26 Apr 2011 Link to this post

    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
  2. Maya
    Admin
    Maya avatar
    4062 posts

    Posted 26 Apr 2011 Link to this post

    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
  3. DevCraft banner
  4. Ravi
    Ravi avatar
    104 posts
    Member since:
    Oct 2012

    Posted 26 Apr 2011 Link to this post

    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
  5. Ravi
    Ravi avatar
    104 posts
    Member since:
    Oct 2012

    Posted 26 Apr 2011 Link to this post

    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.

  6. Answer
    Maya
    Admin
    Maya avatar
    4062 posts

    Posted 26 Apr 2011 Link to this post

    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
  7. Jelena
    Jelena avatar
    2 posts
    Member since:
    Jun 2012

    Posted 23 Jul 2012 Link to this post

    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
  8. Maya
    Admin
    Maya avatar
    4062 posts

    Posted 23 Jul 2012 Link to this post

    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.

  9. Jelena
    Jelena avatar
    2 posts
    Member since:
    Jun 2012

    Posted 23 Jul 2012 Link to this post

    Nice. Thank you!

    Jelena
Back to Top
DevCraft banner