defineTemplateAction Method

Description

If you implement a custom template service, the defineTemplateAction method enables you to define a custom action that can be applied to diagram templates displayed in the editor's template selection window. Each custom action you define will result in a new action button displayed under the template preview area of the template selector. Up to 3 template actions may be defined.

Syntax

.defineTemplateAction( /*String*/ label, /*Function*/ actionFunction)

Parameters

label: String

A string that will be used as the action button's label.

actionFunction: Function

A function that accepts two parameters.

  • ID: String ‐ the ID of the template for which the template action is invoked.
  • refreshFunction: Function ‐ a function that can be called to refresh the template manager. In your action function, call the refreshFunction if the template manager should be refreshed. For example, the template manager window should be refreshed if a template is deleted or its label has been changed by the action function.

This function will be called when the user invokes the template action.

Note: only 3 template actions may be defined. Attempting to add more than 3 will result in an exception.

This method must be used before the startup method is called. defineTemplateAction will throw an exception if called after startup.

Returns

Nothing

Example

editor = new ESDWeb(null, 'editorNode');

editor.defineTemplateAction('Delete', function (templateId, refresh) {
    // Delete template server-side via an ajax request.
    ...
    // refresh the template manager window
    refresh();
});

// Startup the editor with templateServiceUrl enabled.
editor.startup({
    ...
    templateServiceUrl: 'http://www.example.com/REST/'
});