Add to Undo Stack

3 posts, 0 answers
  1. Andrew
    Andrew avatar
    4 posts
    Member since:
    May 2016

    Posted 24 May 2016 Link to this post


    I am writing a number of custom shortcut commands activated by button clicks.  While the commands are firing properly, most of them are not being recognized in the undo stack - i.e. user cannot press the undo button to reverse the command.  When they do press it, they undo a command prior to running the custom command, stepping back to a document version they were not expecting.  My question is, how do I have the undo stack recognize my custom commands and allow the user to undo them?  Here's an example of a function with this issue.

                Telerik.Web.UI.Editor.CommandList["DoubleBottomBorder"] = function(commandName, editor, args) {
                             var elem = editor.getSelectedElement();
                    = "3px double #000000";

    Most of my functions are setting the style attribute of an element and are not using the pasteHtml() method (use of pasteHTML() method seems to work fine with the undo function).



  2. Nikolay
    Nikolay avatar
    84 posts

    Posted 27 May 2016 Link to this post

    Hi Andrew,

    To add a custom command to Undo stack, you should initialize a RadEditor's GenericCommand before your command logic and execute it after that. Here is an example for the DoubleBottomBorder command:
    Telerik.Web.UI.Editor.CommandList["DoubleBottomBorder"] = function(commandName, editor, args) {
        var command = new Telerik.Web.UI.Editor.GenericCommand(commandName, editor.get_contentWindow(), editor);
         var elem = editor.getSelectedElement(); = "3px double #000000";

    Do you need help with upgrading your ASP.NET AJAX, WPF or WinForms projects? Check the Telerik API Analyzer and share your thoughts.
  3. Andrew
    Andrew avatar
    4 posts
    Member since:
    May 2016

    Posted 27 May 2016 in reply to Nikolay Link to this post

    Works like a charm, thank you!
Back to Top