Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
1215
How to get old text in TextChanged
posted

How do you get the old WebDataTree node text value in the TextChanged event?  In other words, a user edits the text of a WebDataTree node and presses Enter.  The TextChanged event fires, and I need to know the previous text value of the DataTreeNode before the change was made.  How can you get that in the event?

Parents
  • 18204
    Suggested Answer
    Offline posted

    Hi raywhite,

    Thank you for posting in our forums!

    You can get the old text of a node during the TextChanging event.  Once the TextChanging event returns and if the event was not cancelled, the node's text will get updated.  If it is not required to check the old text during the TextChanged event, I would recommend handling it during the TextChanging event.

    You can use the following code to store the old text during textChanging and then access it during textChanged.

    var oldText = null;
    function WebDataTree1_NodeEditingTextChanging(sender, eventArgs) {
         oldText = eventArgs.getNode().get_text();
    }
    function WebDataTree1_NodeEditingTextChanged(sender, eventArgs) {
         if (oldText != null) {
            console.log(oldText);
            oldText = null;
        }
    }

    If you need further assistance with this, please let me know.

Reply Children
No Data