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

Editing RadTreeNodes

3 Answers 22 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
Sonia
Top achievements
Rank 1
Sonia asked on 08 Oct 2013, 11:14 AM
I would like to edit RadTreeNodes in a RadWindow and after making changes, update RadTreeView according to those changes.
The idea is to have a context menu with serveral options, one of them would be "Edit node". This action would open a RadWindow with information related to the node. The user would make changes and after changes are saved the treeview (just the treenode) would be updated.

I have tried to implement that but i haven't been able to open a radwindow from context menu.
Do you have an example on how to achieve that?
Thank you,
Sonia.

3 Answers, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 1
answered on 08 Oct 2013, 11:56 AM
Hi Sonia,

Please have a look into the full code that I tried to show a RadWindow on OnClientContextMenuItemClicked event.

ASPX:
<telerik:RadTreeView ID="RadTreeView1" runat="server" OnClientContextMenuItemClicked="OnClientContextMenuItemClicked1">
    <ContextMenus>
        <telerik:RadTreeViewContextMenu ID="RadTreeViewContextMenu1" runat="server">
            <Items>
                <telerik:RadMenuItem runat="server" Text="New">
                </telerik:RadMenuItem>
                <telerik:RadMenuItem runat="server" Text="Edit">
                </telerik:RadMenuItem>
            </Items>
        </telerik:RadTreeViewContextMenu>
    </ContextMenus>
    <Nodes>
        <telerik:RadTreeNode runat="server" Text="OOPS" Value="1">
            <Nodes>
                <telerik:RadTreeNode runat="server" Text="C++" Value="1.1">
                </telerik:RadTreeNode>
                <telerik:RadTreeNode runat="server" Text="Java" Value="1.2">
                </telerik:RadTreeNode>
            </Nodes>
        </telerik:RadTreeNode>
        <telerik:RadTreeNode runat="server" Text="MarkupLanguage" Value="2">
            <Nodes>
                <telerik:RadTreeNode runat="server" Text="HTML" Value="2.1">
                </telerik:RadTreeNode>
                <telerik:RadTreeNode runat="server" Text="XML" Value="2.2">
                </telerik:RadTreeNode>
            </Nodes>
        </telerik:RadTreeNode>
    </Nodes>
</telerik:RadTreeView>
<telerik:RadWindow ID="RadWindow1" runat="server">
    <ContentTemplate>
        <telerik:RadTextBox ID="RadTextBox1" runat="server">
        </telerik:RadTextBox>
    </ContentTemplate>
</telerik:RadWindow>

JavaScript:
<script type="text/javascript">
    function OnClientContextMenuItemClicked1(sender, args) {
        if (args.get_menuItem()._text == "Edit") {
            var radwindow = $find('<%=RadWindow1.ClientID %>');
            radwindow.Show(true);
        }
    }
</script>

Thanks,
Princy.
0
Sonia
Top achievements
Rank 1
answered on 08 Oct 2013, 12:52 PM
Hi Princy,

this is the piece of code for opening the window from the context menu,
but how can i achieve to update content of the treeview according to changes made on radwindow?
As i said i want to use radwindow to edit treenodes. I hope you can help me.

Thanks,
Sonia.
0
Princy
Top achievements
Rank 1
answered on 09 Oct 2013, 06:26 AM
Hi Sonia,

Please try the following JavaScript to set the TextBox Text as RadTreeNode Text in Edit Mode.

JavaScript:
function test() {
    var radwindow = $find('<%=RadWindow1.ClientID %>');
    var radtextbox = $find('<%=RadTextBox1.ClientID %>');
    var radtreeview = $find('<%=RadTreeView1.ClientID %>');
    value = radtextbox.get_value();
    var editednode = radtreeview.findNodeByText(node);
    editednode.startEdit();
    editednode.set_text(value);
    radtreeview.commitChanges();
    radwindow.hide();
}

Thanks,
Princy.
Tags
TreeView
Asked by
Sonia
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 1
Sonia
Top achievements
Rank 1
Share this question
or