Skip to main content
JS

RichEditBuilder.OnCustomCommandExecuted(String) Method

Assigns an event handler to the CustomCommandExecuted event.

Namespace: DevExpress.AspNetCore.RichEdit

Assembly: DevExpress.AspNetCore.RichEdit.v24.1.dll

NuGet Package: DevExpress.AspNetCore.RichEdit

Declaration

public RichEditBuilder OnCustomCommandExecuted(
    string callback
)

Parameters

Name Type Description
callback String

The name of the JavaScript function or the JavaScript function code used to handle the event.

Returns

Type Description
RichEditBuilder

The builder for the Rich Text Editor.

Remarks

The CustomCommandExecuted event occurs after a custom command has been executed on the client side. The event handler receives an argument of the CustomCommandExecutedEventArgs type. The argument’s properties provide information specific to this event.

@(Html.DevExpress().RichEdit("richEdit")
   .Ribbon(ribbon => ribbon
       .Visible(true)
       .ActiveTabIndex(1)
       .Tabs(tabs => {
           tabs.Clear();            
           tabs.Add()
               .Title("Email")
               .Items(items => {
                   items.AddButton()
                       .Text("Insert Email Signature")
                       .CommandName("insertEmailSignature")
                       .ShowText(true)
                       .Icon("user");
                   items.AddButton()
                       .Text("Send Email")
                       .CommandName("sendEmail")
                       .ShowText(true)
                       .Icon("email");
                   items.AddPrintDocumentItem().BeginGroup(true);
                   items.AddDownloadDocumentItem();
               });
       })
   )
   .OnCustomCommandExecuted("function(s,e) {
       switch (e.commandName) {
           case 'insertEmailSignature':
               s.document.insertParagraph(s.document.length);
               s.document.insertText(s.document.length, '_________');
               s.document.insertParagraph(s.document.length);
               s.document.insertText(s.document.length, 'Best regards,');
               s.document.insertParagraph(s.document.length);
               s.document.insertText(s.document.length, 'John Smith');
               s.document.insertParagraph(s.document.length);
               s.document.insertText(s.document.length, 'john@example.com');
               s.document.insertParagraph(s.document.length);
               s.document.insertText(s.document.length, '+1 (818) 844-0000');
               break;
           case 'sendEmail':
               var text = s.document.getText();
               var mailto_link = 'mailto:bob@example.com?subject=Test&body=' + encodeURIComponent(text);
               window = window.open(mailto_link, 'emailWindow');
               if(window && window.open && !window.closed)
                   window.close();
               break;
       }
   }")
   // ...

Run Demo: Ribbon Customization Run Demo: Context Menu Customization

See Also