Back to Devexpress

ASPxClientDiagram.RequestEditOperation Event

aspnet-js-aspxclientdiagram-e882df9d.md

latest4.1 KB
Original Source

ASPxClientDiagram.RequestEditOperation Event

Allows you to prohibit an edit operation at run time.

Declaration

ts
RequestEditOperation: ASPxClientEvent<ASPxClientDiagramRequestEditOperationEventHandler<ASPxClientDiagram>>

Event Data

The RequestEditOperation event's data class is ASPxClientDiagramRequestEditOperationEventArgs. The following properties provide information specific to this event:

PropertyDescription
allowedSpecifies whether the edit operation is allowed.
argsContains information about the processed shape or connector.
operationIdentifies the operation currently being processed.
reasonIdentifies the reason why the event is raised.

Remarks

The RequestEditOperation event requests information about an edit operation’s availability. The event argument contains the following parameters.

  • The reason parameter identifies why the control requires the information.

  • The operation parameter identifies the edit operation. Note that if you want to disable a specific operation type for the entire diagram, you can also set an Allow{Operation} property to false. The table below lists all available operations.

  • The args parameter contains information about the shape or connector that takes part in the edit operation. The parameter’s value type depends on the operation.

  • Set the allowed parameter to false to prohibit the operation.

  • ASPX

aspx
<dx:ASPxDiagram ID="Diagram" runat="server" Width="100%" Height="600px">
    <ClientSideEvents RequestEditOperation="onRequestEditOperation" />
    ...
</dx:ASPxDiagram>
javascript
function onRequestEditOperation(s, e) {
    if(e.operation === DiagramEditOperation.ResizeShape) {
        if(e.args.newSize.width < 1 || e.args.newSize.height < 0.75) {
            if(e.reason !== DiagramRequestEditOperationReason.CheckUIElementAvailability)
                showWarning("The shape size is too small.");
            e.allowed = false;
        }
    }
    else if(e.operation === DiagramEditOperation.ChangeShapeText) {
        if(e.args.text === "") {
            if(e.reason !== DiagramRequestEditOperationReason.CheckUIElementAvailability)
                showWarning("A shape text cannot be empty.");
            e.allowed = false;
        }
    }
    ...
}

Run Demo: Editing Restrictions

When a user pastes or clones several items in a diagram, the control adds the items to the model one by one. For each added item, the RequestEditOperation event fires. In the event handler, you can access the processed item. However, if you call the GetItemById(id) method to access an attached connector (see the attachedConnectorIds property) or a container’s child item (see the containerChildItemIds property), you can get the undefinedresult if the item is not added to the model yet.

See Also

Restrict Edit Operations

SettingsEditing

ASPxClientDiagram Class

ASPxClientDiagram Members