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

Update the text of the edited node.

1 Answer 45 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
Andres
Top achievements
Rank 1
Andres asked on 13 Sep 2011, 01:32 AM
hi, in the code behind I call a Confirm box in javascript(client-side), with a button that says Yes an other that says No. If the user clicks NO, the method CancelNodeEdited() is called. So I pass the old description as the argument. The problem is that if the user edit the node and enter a new description, then the Confirm box is showed. If the user clicks No, the new description is showed and the old description is not taken. How can I fix this problem ?

if ((dtProjects.Rows.Count > 0) && (checkClientAdminRole()))
                                    {
                                        // set old value to cancel action
                                        e.Node.Attributes["OldNodeDescription"] = e.Node.Attributes["NodeDescription"];

                                        // create warning message
                                        sMessage = "Are you sure you want to edit the Taxanomy? The Tax Return Line is used within your Client by:\\n" + sOtherProjectName;
                                        sMessage = sMessage.Replace("\\", "\\\\").Replace("'", "\\'").Replace("\"", "\\\"");

                                        // register script for user confirmation
                                        sScript = @"var resultado = confirm('" + sMessage + "'); if (!resultado) CancelNodeEdited('" + e.Node.Attributes["OldNodeDescription"] + "');";
                                        ClientScript.RegisterStartupScript(typeof(Page), "jsEditNode", sScript, true);
                                       
                                        // set new value
                                        e.Node.Text = e.Node.Attributes["TaxonomyNotation"] + " " + nodeText;

and in the aspx;

function CancelNodeEdited(oldValue) {   
            tree = document.getElementById('<%=trTaxonomy.ClientID%>');           
            var node = tree.FindNodeByAttribute("NodeDescription", oldValue);                       
            nodetext = node.get_attributes().getAttribute("OldNodeDescription");           
            node.get_attributes().setAttribute("NodeDescription", nodetext);
            node.set_text(node.get_attributes().getAttribute("TaxonomyNotation") + " " + nodetext);
            node.get_attributes().setAttribute("OldNodeDescription", null);
    }

1 Answer, 1 is accepted

Sort by
0
Dimitar Terziev
Telerik team
answered on 15 Sep 2011, 01:20 PM
Hello Andres,

In the sample code you have provided it seems to me that you are not referencing the client object of the RadTreeView. You are getting reference to the DOM element instead and thus you could not call any client-side methods.

You should replace the tree = document.getElementById('<%=trTaxonomy.ClientID%>'); with tree = $find('<%=trTaxonomy.ClientID%>');

Best wishes,
Dimitar Terziev
the Telerik team
Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal
Tags
TreeView
Asked by
Andres
Top achievements
Rank 1
Answers by
Dimitar Terziev
Telerik team
Share this question
or