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

While editing the node,if i give empty it should give default string "Runjith"

3 Answers 13 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
Runjith
Top achievements
Rank 2
Runjith asked on 16 Jul 2014, 11:12 AM
Hi,

I am using RadTreeView control.I have implemented context menu for renaming,While renaming the node if i delete the text and press tab it should give default string "Runjith".

I tryed under this "treeview_Edited(object sender, RadTreeViewItemEditedEventArgs e)" event

 e.Source = "Runjith";
 treeview.SelectedItem = (RunjithNode)e.Source;

I am getting error for this line(treeview.SelectedItem = (RunjithNode)e.Source;)"Additional information: Unable to cast object of type 'System.String' to type 'xyz.namespace.Runjith'." Runjith class inherits RadTreeViewItem.

How to fix please help me ASAP................

BR,Runjith

3 Answers, 1 is accepted

Sort by
0
Petar Mladenov
Telerik team
answered on 18 Jul 2014, 09:02 AM
Hello Runjith,

We prepared a sample project for you in which we use the PreviewEdited event of the RadTreeView in databound scenario. If you edit an item, delete its header and press Tab to exit the edit mode, the string "Empty" will be displayed as a Header.
private void treeA_PreviewEdited(object sender, RadTreeViewItemEditedEventArgs e)
       {
           var dataitem = e.NewValue as DataItem;
           if (dataitem != null && dataitem.Name == string.Empty)
           {
               dataitem.Name = "Empty";
           }
       }
Please let us know if this is what you need.

Regards,
Petar Mladenov
Telerik
 
Check out Telerik Analytics, the service which allows developers to discover app usage patterns, analyze user data, log exceptions, solve problems and profile application performance at run time. Watch the videos and start improving your app based on facts, not hunches.
 
0
Runjith
Top achievements
Rank 2
answered on 18 Jul 2014, 11:10 AM
Hi,

I want to assign this "Empty" value to my selected RadTreeView item.I am trying to assign

 Treeviewitem.selecteditem="Empty";

it is giving error.How can i assign this "Empty" value to my Selected TreeViewItem inside the event

tv_PreviewEdited(object sender, RadTreeViewItemEditedEventArgs e)
{
 var dataitem = e.NewValue as DataItem;
            if (dataitem == null)
            {
                e.Source = "Empty";// Treeviewitem.selecteditem="Empty";

            }
}

Regards,
Ranjith

 
0
Petar Mladenov
Telerik team
answered on 21 Jul 2014, 09:08 AM
Hello Runjith,

If I understand correctly, you edit an item which is not the selected one, and you need to change the header of the selected one in the Edited event handler. If this is true, this seems to me user unfriendly - it is somehow unexpected to edit an item which is not selected.
As for the concrete question - you can set  the header of the SelectedItem if it returns RadTreeViewItem, if it returns a DataItem (the ViewModel to which the RadTreeViewItem is bound) set the property to which the Header of the RadTreeViewItem is bound.
If I understand your scenario incorrectly, is it possible for you to send us more detailed explanation of your use case in steps ? This way we would be better able to advice you.

Regards,
Petar Mladenov
Telerik
 
Check out Telerik Analytics, the service which allows developers to discover app usage patterns, analyze user data, log exceptions, solve problems and profile application performance at run time. Watch the videos and start improving your app based on facts, not hunches.
 
Tags
TreeView
Asked by
Runjith
Top achievements
Rank 2
Answers by
Petar Mladenov
Telerik team
Runjith
Top achievements
Rank 2
Share this question
or