Back to Devexpress

CustomCommandExecutedEvent Class

aspnetcore-js-devexpress-dot-richedit-3bce1667.md

latest3.7 KB
Original Source

CustomCommandExecutedEvent Class

An event that occurs after a custom command has been executed on the client side.

Declaration

ts
export class CustomCommandExecutedEvent extends RichEditEvent<CustomCommandExecutedEventArgs>

Remarks

You can define the CustomCommandExecuted event handler either at the server side, at the client side, or at runtime.

Use the OnCustomCommandExecuted(String) method to specify the event handler.

cshtml
@(Html.DevExpress().RichEdit("richEdit")
 .OnCustomCommandExecuted("function(s,e) {
   switch (e.commandName) {
     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;
   }
 }")
 // ...

Use the customCommandExecuted property to specify the event handler.

javascript
const options = DevExpress.RichEdit.createOptions();
options.events.customCommandExecuted = function(s,e) {
  switch (e.commandName) {
    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;
  }
};

The customCommandExecuted property provides access to the addHandler(handler), removeHandler(handler), and clearHandlers methods that allow you to dynamically add and remove event handlers.

javascript
richEdit.events.customCommandExecuted.addHandler(function(s, e) {
  switch (e.commandName) {
    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;
  }
});

The event handler receives an argument of the CustomCommandExecutedEventArgs type. The argument’s properties provide information specific to this event.

Inherited Members

addHandler(handler)

clearHandlers

isEmpty

removeHandler(handler)

Inheritance

Event<TSource, TEventArgs> RichEditEvent<TEventArgs> CustomCommandExecutedEvent

See Also

Client-Side Events