Treeview Selction and Edit the node

2 posts, 0 answers
  1. Baskar
    Baskar avatar
    9 posts
    Member since:
    Feb 2009

    Posted 12 Sep 2011 Link to this post

    Dear Experts,
    am using tree view selection change event to get the selected item and am able to get the selected item by using the below code

    void treeView_SelectionChanged(object sender, Telerik.Windows.Controls.SelectionChangedEventArgs e)
            {
                RadTreeView tv = e.OriginalSource as RadTreeView;

                //get the selected Item from the treeview.
                selectedItem = tv.SelectedItem as RadTreeViewItem;

                if (treeView.SelectedContainer != null && this.treeView.SelectedContainer != selectedItem)
                {
                    this.treeView.SelectedContainer.IsInEditMode = false;
                }

                if (selectedItem != null)
                {
                    selectedItem.IsInEditMode = true;
                    selectedItem.BeginEdit();
                }
            }

    and i have add button_click event ann call the add method as shown below

     private void AddItem()
            {
                if (selectedItem  == null)
                {               
                        RadTreeViewItem newItem = new RadTreeViewItem()
                        {
                            Header = "New root"
                        };
                        treeView.Items.Add(newItem);
                       
                }
                else
                {
                    RadTreeViewItem newItem = new RadTreeViewItem()
                    {
                        Header = "New Child"
                    };
                    selectedItem.Items.Add(newItem);                                     
                }                     
               
    The problem is when i add the new node, and its in editable, and am able to edit, but when click on the each node in the treeview all the item in the text gets disabled. i don't whats wrong in my code.

    i need to add the new node with the edit functionality.

    Thanks in Advance.
  2. Petar Mladenov
    Admin
    Petar Mladenov avatar
    2891 posts

    Posted 15 Sep 2011 Link to this post

    Hello Baskar,

     Could you please check out this thread and the post from Hristo from 12 September 2011. He describes two issues with the edit mode of the RadTreeView. Can you confirm that one of those has to do with your scenario?

    Greetings,
    Petar Mladenov
    the Telerik team

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

  3. DevCraft banner
Back to Top