Back to Devexpress

RichEditBuilder.OnCustomCommandExecuted(String) Method

aspnetcore-devexpress-dot-aspnetcore-dot-richedit-dot-richeditbuilder-dot-oncustomcommandexecuted-x28-system-dot-string-x29.md

latest3.9 KB
Original Source

RichEditBuilder.OnCustomCommandExecuted(String) Method

Assigns an event handler to the CustomCommandExecuted event.

Namespace : DevExpress.AspNetCore.RichEdit

Assembly : DevExpress.AspNetCore.RichEdit.v25.2.dll

NuGet Package : DevExpress.AspNetCore.RichEdit

Declaration

csharp
public RichEditBuilder OnCustomCommandExecuted(
    string callback
)

Parameters

NameTypeDescription
callbackString

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

|

Returns

TypeDescription
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.

cshtml
@(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, '[email protected]');
               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:[email protected]?subject=Test&body=' + encodeURIComponent(text);
               window = window.open(mailto_link, 'emailWindow');
               if(window && window.open && !window.closed)
                   window.close();
               break;
       }
   }")
   // ...

Run Demo: Ribbon CustomizationRun Demo: Context Menu Customization

See Also

RichEditBuilder Class

RichEditBuilder Members

DevExpress.AspNetCore.RichEdit Namespace