ASPxClientDiagram.RequestEditOperation Event
Allows you to prohibit an edit operation at run time.
Declaration
RequestEditOperation: ASPxClientEvent<ASPxClientDiagramRequestEditOperationEventHandler<ASPxClientDiagram>>
Event Data
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. |
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 CheckUIElementAvailability value indicates that the control is updating the UI. Set the allowed property to
false
to hide the UI element associated with the specified operation.The ModelModification value indicates if a user attempts an edit operation. You can specify whether to allow the operation and display an error message if a user tries to execute a prohibited action.
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.Operation User action / IU update operation causes the event to be raised AddShape A user is about to add a shape / The control determines the Paste command’s visibility. AddShapeFromToolbox The control determines the visibility of a shape in the toolbox or context toolbox. BeforeChangeConnectorText A user is about to edit a connector’s text. BeforeChangeShapeText A user is about to edit a shape’s text. ChangeConnection A user is about to link or delink a connector from a shape / The control determines a connection point’s visibility. ChangeConnectorPoints A user changed a connector’s points. ChangeConnectorText A user changed a connector’s text. ChangeShapeText A user changed a shape’s text. DeleteConnector A user is about to delete a connector / The control determines the Cut and Delete commands’ visibility. DeleteShape A user is about to delete a shape / The control determines the visibility of the Cut and Delete commands. MoveShape A user moved a shape. ResizeShape A user resized a shape. 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;
}
}
...
}
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 undefined
result if the item is not added to the model yet.