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

4 posts, 0 answers
  1. Runjith
    Runjith avatar
    26 posts
    Member since:
    Mar 2014

    Posted 16 Jul 2014 Link to this post

    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
  2. Petar Mladenov
    Admin
    Petar Mladenov avatar
    2891 posts

    Posted 18 Jul 2014 Link to this post

    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.
     
  3. UI for WPF is Visual Studio 2017 Ready
  4. Runjith
    Runjith avatar
    26 posts
    Member since:
    Mar 2014

    Posted 18 Jul 2014 in reply to Petar Mladenov Link to this post

    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

     
  5. Petar Mladenov
    Admin
    Petar Mladenov avatar
    2891 posts

    Posted 21 Jul 2014 Link to this post

    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.
     
Back to Top