So my question is, how -- using js and/or code-behind -- can I clear the Undo history?
5 Answers, 1 is accepted
The following example demonstrates how to clear the history:
<
telerik:radeditor
runat
=
"server"
ID
=
"RadEditor1"
></
telerik:radeditor
>
<
div
onclick
=
"SetContent(this);"
id
=
"Div1"
>sample content DIV 1</
div
>
<
div
onclick
=
"SetContent(this);"
id
=
"Div2"
>sample content DIV 2</
div
>
<
script
type
=
"text/javascript"
>
function SetContent(oDiv) {
var editor = $find("<%=RadEditor1.ClientID%>");
editor.get_commandsManager()._clearCommandsToRedo();
var manager = editor.get_commandsManager();
var length = manager.getCommandsToUndo().length;
for (var i = 0; i <
length
; i++) {
manager.removeCommandAt(0);
}
editor.get_document()
.body.innerHTML
=
oDiv
.innerHTML;
}
</script>
I hope this helps.
Greetings,
Dobromir
the Telerik team
Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.

Thank you for the additional information.
Here is how to reset the Undo list of RadEditor Classic:
<rade:radEditor id="RadEditor1" ImagesPaths="~/" UploadImagesPaths="~/" runat="server" >
sample content
</rade:radEditor>
<div onclick="SetContent(this);" id="Div1">sample content DIV 1</div>
<div onclick="SetContent(this);" id="Div2">sample content DIV 2</div>
<script type="text/javascript">
function SetContent(oDiv)
{
var editor = <%=RadEditor1.ClientID%>
editor.CommandsManager.ClearCommandsToRedo();
var manager = editor.CommandsManager;
var length = manager.GetCommandsToUndo().length;
for (var i=0; i < length; i++)
{
manager.RemoveCommandAt(0);
}
editor.Document.body.innerHTML = oDiv.innerHTML;
}
</script>
Best regards,
Rumen
the Telerik team
Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.

David the below example is great. I will need one more thing. When there is nothing in history how can I make the Undo button disabled. When the history is cleared the button still remains active. thans.
function SetContent(oDiv) {
var editor = $find("<%=RadEditor1.ClientID%>");
editor.get_commandsManager()._clearCommandsToRedo();
var manager = editor.get_commandsManager();
var length = manager.getCommandsToUndo().length;
for (var i = 0; i <
length
; i++) {
manager.removeCommandAt(0);
}
editor.get_document()
.body.innerHTML
=
oDiv
.innerHTML;
}

var myCancelTool = sender.getToolByName("Cancel");
myCancelTool.setState(-1);