You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: blazor/diagram/swimlane/lane/interaction.md
+94-13Lines changed: 94 additions & 13 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -50,9 +50,11 @@ The following image shows children interaction in lane.
50
50
51
51
## How to restrict nodes from being dragged or repositioned outside their assigned swimlane
52
52
53
-
To restrict child nodes to their swimlane, set their [Constraints](https://help.syncfusion.com/cr/blazor/Syncfusion.Blazor.Diagram.Node.html#Syncfusion_Blazor_Diagram_Node_Constraints) to include [NodeConstraints.AllowDragWithinSwimlane](https://help.syncfusion.com/cr/blazor/Syncfusion.Blazor.Diagram.NodeConstraints.html#Syncfusion_Blazor_Diagram_NodeConstraints_AllowDragWithinSwimlane). By default, nodes can move freely; however, with this constraint enabled, a node can only be dragged within the bounds of its owning swimlane. Attempts to move it across lane or swimlane boundaries are prevented.
54
-
55
-
The following example demonstrates one node restricted to its swimlane, while another remains unrestricted for comparison.
53
+
By default, nodes in a swimlane can be moved freely within and outside the swimlane boundaries. When **NodeConstraints.AllowDragWithinSwimlane** is enabled by the nodes [Constraints](https://help.syncfusion.com/cr/blazor/Syncfusion.Blazor.Diagram.Node.html#Syncfusion_Blazor_Diagram_Node_Constraints) property, nodes cannot be dragged outside the swimlane. If an attempt is made to move a node beyond the swimlane’s boundaries, a “not allowed” cursor appears, indicating the restriction.
54
+
55
+
To enforce this restriction for all child nodes within swimlanes, set the constraint during node initialization in the [NodeCreating](https://help.syncfusion.com/cr/blazor/Syncfusion.Blazor.Diagram.SfDiagramComponent.html#Syncfusion_Blazor_Diagram_SfDiagramComponent_NodeCreating) event. The constraint can also be enabled or disabled dynamically at runtime, for example, via a button click.
56
+
57
+
The following example demonstrates a node with the text "AllowDrag Within Swimlane" restricted to its swimlane boundaries:
56
58
57
59
```cshtml
58
60
@using Syncfusion.Blazor.Diagram
@@ -115,7 +117,13 @@ The following example demonstrates one node restricted to its swimlane, while an
@@ -145,21 +153,94 @@ The following example demonstrates one node restricted to its swimlane, while an
145
153
else if (obj is Node node)
146
154
{
147
155
node.Style = new ShapeStyle()
148
-
{
149
-
Fill = "#5b9bd5",
150
-
StrokeColor = "#5b9bd5"
151
-
};
156
+
{
157
+
Fill = "#5b9bd5",
158
+
StrokeColor = "#5b9bd5"
159
+
};
152
160
}
153
161
}
154
162
}
155
163
156
164
```
157
-
A complete working sample can be downloaded from [GitHub](https://github.com/SyncfusionExamples/Blazor-Diagram-Examples/tree/master/UG-Samples/Nodes/ActionsofNodes/AddNode)
158
165
159
-

166
+
The following example demonstrates enabling or disabling `AllowDragWithinSwimlane` dynamically at runtime by a button click.
DiagramObjectCollection<Swimlane> SwimlaneCollections = new DiagramObjectCollection<Swimlane>();
160
180
161
-
>**Note:**
162
-
* To restrict a node to its owning swimlane, add [NodeConstraints.AllowDragWithinSwimlane](https://help.syncfusion.com/cr/blazor/Syncfusion.Blazor.Diagram.NodeConstraints.html#Syncfusion_Blazor_Diagram_NodeConstraints_AllowDragWithinSwimlane) to the node’s `Constraints` property.
181
+
protected override void OnInitialized()
182
+
{
183
+
// A swimlane is created and stored in the swimlanes collection.
184
+
Swimlane swimlane = new Swimlane()
185
+
{
186
+
Header = new SwimlaneHeader()
187
+
{
188
+
Annotation = new ShapeAnnotation()
189
+
{
190
+
Content = "SALES PROCESS FLOW CHART"
191
+
},
192
+
Height = 50,
193
+
},
194
+
OffsetX = 400,
195
+
OffsetY = 200,
196
+
Height = 120,
197
+
Width = 450,
198
+
Lanes = new DiagramObjectCollection<Lane>()
199
+
{
200
+
new Lane()
201
+
{
202
+
Height = 100,
203
+
Header = new SwimlaneHeader()
204
+
{
205
+
Width = 30,
206
+
Annotation = new ShapeAnnotation(){ Content = "Consumer" }
207
+
},
208
+
Children = new DiagramObjectCollection<Node>()
209
+
{
210
+
new Node()
211
+
{
212
+
Height = 50,
213
+
Width = 100,
214
+
LaneOffsetX = 250,
215
+
LaneOffsetY = 30
216
+
},
217
+
}
218
+
},
219
+
}
220
+
};
221
+
// Add swimlane
222
+
SwimlaneCollections.Add(swimlane);
223
+
}
224
+
225
+
public void AllowDrag()
226
+
{
227
+
if (diagramComponent.SelectionSettings.Nodes.Count > 0)
228
+
{
229
+
if (diagramComponent.SelectionSettings.Nodes[0].Constraints.HasFlag(NodeConstraints.AllowDragWithinSwimlane))
* To enforce this restriction for all child nodes within swimlanes, set the [Constraints](https://help.syncfusion.com/cr/blazor/Syncfusion.Blazor.Diagram.Node.html#Syncfusion_Blazor_Diagram_Node_Constraints) during node initialization in the NodeCreating event.
244
+
{% previewsample "https://blazorplayground.syncfusion.com/embed/BjVeMBiRzuEmRSmS?appbar=true&editor=true&result=true&errorlist=true&theme=bootstrap5" backgroundimage "[Allow Drag Within Swimlane](../Swimlane-images/AllowDragWithinSwimlane.gif)" %}
165
245
246
+
A complete working sample can be downloaded from [GitHub](https://github.com/SyncfusionExamples/Blazor-Diagram-Examples/tree/master/UG-Samples/Swimlanes/Lane/AllowDragWithinSwimlane/AllowDragWithinSwimlane)
0 commit comments