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

Whats the difference between OnClientCommandExecuting and RadEditorCommandList?

1 Answer 115 Views
Editor
This is a migrated thread and some comments may be shown as answers.
Andy
Top achievements
Rank 1
Andy asked on 04 Nov 2011, 08:13 PM
I've customized the editor toolbars by removing some buttons while adding my own custom buttons.  I've implemented a clientside OnClientCommandExecuting handler to intercept and cancel keyboard shortcuts to the removed editor buttons.  I also want to handle click events from the editor toolbar custom buttons. 

Telerik documentation says to add onclick handlers to the editor's RadEditorCommandList.  But, I've noticed that custom button click events are first processed by the OnClientCommandExecuting handler before they get to the RadEditorCommandList handlers.  

What is the difference between using these two handlers?  The custom buttons will instigate serverside save and saveas functionality via an ajax post.  I'ld prefer to combine everything into the OnClientCommandExecuting handler, and to launch save/saveas ajax posts from there.  After each launch I will cancel the click event.


<script type="text/javascript">
  
    function OnClientCommandExecuting(editor, args) {
       if ("Save" == args.get_commandName()) {
            alert("OnClientCommandExecuting Save"); 
            args.set_cancel(true);          
        } else if ("SaveAs" == args.get_commandName()) {
            alert("OnClientCommandExecuting SaveAs");
            args.set_cancel(true); 
        }
    } //EOF OnClientCommandExecuting
  
</script>
  
<telerik:RadEditor ID="telerikeditor" Runat="server" 
                   OnClientLoad="onClientLoad"
                   OnClientCommandExecuting="OnClientCommandExecuting">
    <Tools>
        <telerik:EditorToolGroup Tag="grpInputOutput">
            <telerik:EditorTool ImageUrl="Images/radeditorSave.gif" 
                Name="Save" ShowText="False" 
                Text="Save" />
            <telerik:EditorTool ImageUrl="Images/radeditorSaveAs.gif" 
                Name="SaveAs" ShowText="False" 
                Text="Save As" />
            <telerik:EditorSeparator />     
        </telerik:EditorToolGroup>
     </Tools>
     <Content>
     </Content>
</telerik:RadEditor>    
          
<script type="text/javascript"
     //locate this script after the radeditor HTML declaration
    RadEditorCommandList["Save"] = function(commandName, editor, oTool) {
        alert("RadEditorCommandList Save");
    }
</script>

1 Answer, 1 is accepted

Sort by
0
Rumen
Telerik team
answered on 09 Nov 2011, 11:18 AM
Hi Andy ,

Yes, the OnClientCommandExecuting event is executed before the RadEditorCommandList so that you can cancel the command execution. This is more suitable for canceling the built-in commands, but of course works for custom ones. You can implement your solution by combining everything into the OnClientCommandExecuting handler, and to launch save/saveas ajax posts from there.


Best wishes,
Rumen
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now
Tags
Editor
Asked by
Andy
Top achievements
Rank 1
Answers by
Rumen
Telerik team
Share this question
or