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

TreeView Edited event NewValue and OldValue

7 Answers 109 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
Lauren Nickerson
Top achievements
Rank 1
Lauren Nickerson asked on 23 Dec 2009, 11:05 PM
Hi, so I'm in this event I need the old value to do some evaluation, but instead, I get the NewValue on both objects:

private void treeViewExperimentExplorer_Edited(object sender, RadTreeViewItemEditedEventArgs e) 
    string newName = e.NewValue.ToString(); 
    string oldName = e.OldValue.ToString(); 

In there both newName and oldName have the new value. How can I get the previous value in there?

Thanks!

7 Answers, 1 is accepted

Sort by
0
Miroslav
Telerik team
answered on 28 Dec 2009, 05:22 PM
Hi Lauren Nickerson,

Unfortunately when the TreeView uses an ItemEditTemplate (i.e. it is bound) it will not populate these properties. They contain just the data item that the TreeView is bound to.

We are looking to enable these properties for the Q1 release of the controls when the TreeView is bound.

In the meantime I can suggest storing the value that you need in a field when editing starts and then refering to it if you need to when editing ends.

Regards,
Miroslav
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
Lauren Nickerson
Top achievements
Rank 1
answered on 28 Dec 2009, 05:49 PM
That was plan B. Thanks!
0
Menny
Top achievements
Rank 1
answered on 29 Jan 2012, 10:31 AM
its 2012 now and this still happens
0
Kiril Stanoev
Telerik team
answered on 01 Feb 2012, 05:34 PM
Hello Menny,

The previously mentioned behavior is by design. Our suggestion is to use the PreviewEdited and Edited events to distinguish between the new and old values. Please take a look at the attached project for further reference.

Greetings,
Kiril Stanoev
the Telerik team

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

0
Menny
Top achievements
Rank 1
answered on 05 Feb 2012, 12:51 PM
yeh, figured it out
0
Albert
Top achievements
Rank 1
answered on 06 Feb 2013, 04:42 PM
Hello Kiril,

I ran the project in 269235.zip , but it appears that this.oldTitle is always equal to the newly edited value. I am unable to find the value before editing (ie. the oldValue). What am I missing here?

Kind Regards,
Albert
0
Albert
Top achievements
Rank 1
answered on 06 Feb 2013, 04:51 PM
Okay, I figured it out.

I handled the EditStarted event to store the value before the edit occurs:

        private void treeView1_EditStarted(object sender, Telerik.Windows.Controls.RadTreeViewItemEditedEventArgs e)
        {
            this.titleBeforeEdit = (e.OldValue as DataItem).Title;            
        }

Kind Regards,
Albert
Tags
TreeView
Asked by
Lauren Nickerson
Top achievements
Rank 1
Answers by
Miroslav
Telerik team
Lauren Nickerson
Top achievements
Rank 1
Menny
Top achievements
Rank 1
Kiril Stanoev
Telerik team
Albert
Top achievements
Rank 1
Share this question
or