aspnet-js-aspxclientdiagram-e882df9d.md
Allows you to prohibit an edit operation at run time.
RequestEditOperation: ASPxClientEvent<ASPxClientDiagramRequestEditOperationEventHandler<ASPxClientDiagram>>
The RequestEditOperation event's data class is ASPxClientDiagramRequestEditOperationEventArgs. The following properties provide information specific to this event:
| Property | Description |
|---|---|
| allowed | Specifies whether the edit operation is allowed. |
| args | Contains information about the processed shape or connector. |
| operation | Identifies the operation currently being processed. |
| reason | Identifies the reason why the event is raised. |
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.
<dx:ASPxDiagram ID="Diagram" runat="server" Width="100%" Height="600px">
<ClientSideEvents RequestEditOperation="onRequestEditOperation" />
...
</dx:ASPxDiagram>
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