Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
b135503
982382: Documentation for Allow drag within swimlane
BalaVigneshRaviChandran Dec 4, 2025
e37a0e4
982382: Documentation for Allow drag within swimlane
BalaVigneshRaviChandran Dec 4, 2025
78f4f9c
Merge branch 'development' into ES-982382-NodeDragRes
BalaVigneshRaviChandran Dec 4, 2025
eb85e40
982382: Documentation for Allow drag within swimlane
BalaVigneshRaviChandran Dec 16, 2025
40901bb
Merge branch 'ES-982382-NodeDragRes' of https://github.com/syncfusion…
BalaVigneshRaviChandran Dec 16, 2025
e25b50f
982382: Documentation for Allow drag within swimlane
BalaVigneshRaviChandran Dec 16, 2025
9c0519b
982382: Documentation for Allow drag within swimlane
SuganthiK963 Dec 16, 2025
a6960b9
982382: Documentation for Allow drag within swimlane
BalaVigneshRaviChandran Dec 16, 2025
19803c3
982382: Documentation for Allow drag within swimlane
BalaVigneshRaviChandran Dec 16, 2025
a5d7811
982382: Documentation for Allow drag within swimlane
BalaVigneshRaviChandran Dec 16, 2025
9ee1f3a
982382: Documentation for Allow drag within swimlane
BalaVigneshRaviChandran Dec 16, 2025
e201e45
982382: Documentation for Allow drag within swimlane
SuganthiK963 Dec 16, 2025
c0ba221
982382: Documentation for Allow drag within swimlane
BalaVigneshRaviChandran Dec 16, 2025
aff5820
982382: Documentation for Allow drag within swimlane
BalaVigneshRaviChandran Dec 16, 2025
f747660
982382: Documentation for Allow drag within swimlane
BalaVigneshRaviChandran Dec 16, 2025
ae67595
982382: Update review concerns
SuganthiK963 Dec 16, 2025
b149457
982382: Update review concerns
SuganthiK963 Dec 16, 2025
03d85e2
982382: update review concerns
SuganthiK963 Dec 16, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions blazor/diagram/constraints.md
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,7 @@ The [Constraints](https://help.syncfusion.com/cr/blazor/Syncfusion.Blazor.Diagra
|[Resize](https://help.syncfusion.com/cr/blazor/Syncfusion.Blazor.Diagram.NodeConstraints.html#Syncfusion_Blazor_Diagram_NodeConstraints_Resize)|Enables or Disables the expansion or compression of a node.|
|[Inherit](https://help.syncfusion.com/cr/blazor/Syncfusion.Blazor.Diagram.NodeConstraints.html#Syncfusion_Blazor_Diagram_NodeConstraints_Inherit)|Enables the node to inherit the interaction option from the parent object.|
|[RoutingObstacle](https://help.syncfusion.com/cr/blazor/Syncfusion.Blazor.Diagram.NodeConstraints.html#Syncfusion_Blazor_Diagram_NodeConstraints_RoutingObstacle)|Enables or disables the node to be treated as obstacle while in routing.|
|[AllowDragWithinSwimlane](https://help.syncfusion.com/cr/blazor/Syncfusion.Blazor.Diagram.NodeConstraints.html#Syncfusion_Blazor_Diagram_NodeConstraints_AllowDragWithinSwimlane)|Restricts a node’s movement strictly within the swimlane boundaries.|
|[Default](https://help.syncfusion.com/cr/blazor/Syncfusion.Blazor.Diagram.NodeConstraints.html#Syncfusion_Blazor_Diagram_NodeConstraints_Default)|Enables all default constraints for the node.|

The following example shows how to disable the `Rotate` constraint from the default node constraints.
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
197 changes: 197 additions & 0 deletions blazor/diagram/swimlane/lane/interaction.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,3 +47,200 @@ The following image shows how to swap lanes.
The following image shows children interaction in lane.

![Lane Children Interaction](../Swimlane-images/Child_Interaction.gif)

## How to restrict nodes from being dragged outside their swimlane

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.

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 following example demonstrates a node with the text "AllowDrag Within Swimlane" restricted to its swimlane boundaries:

```cshtml
@using Syncfusion.Blazor.Diagram

<SfDiagramComponent Height="600px" Swimlanes="@SwimlaneCollections" NodeCreating="@OnNodeCreating" >
<SnapSettings Constraints="SnapConstraints.None"></SnapSettings>
</SfDiagramComponent>

@code
{
//Define diagram's swimlane collection
private DiagramObjectCollection<Swimlane> SwimlaneCollections = new DiagramObjectCollection<Swimlane>();

protected override void OnInitialized()
{
// A swimlane is created and stored in the swimlanes collection.
Swimlane swimlane = new Swimlane()
{
Header = new SwimlaneHeader()
{
Annotation = new ShapeAnnotation()
{
Content = "SALES PROCESS FLOW CHART"
},
Height = 50,
},
OffsetX = 400,
OffsetY = 200,
Height = 120,
Width = 450,
Lanes = new DiagramObjectCollection<Lane>()
{
new Lane()
{
Height = 100,
Header = new SwimlaneHeader()
{
Width = 30,
Annotation = new ShapeAnnotation(){ Content = "Consumer" }
},
Children = new DiagramObjectCollection<Node>()
{
new Node()
{
Height = 50,
Width = 100,
LaneOffsetX = 100,
LaneOffsetY = 30,
// To enable AllowDragWithinSwimlane to restrict movement outside the swimlane
Constraints = NodeConstraints.Default | NodeConstraints.AllowDragWithinSwimlane ,
Annotations = new DiagramObjectCollection<ShapeAnnotation>()
{
new ShapeAnnotation()
{
Content="AllowDrag Within Swimlane",
Style= new TextStyle()
{
TextOverflow = TextOverflow.Wrap, TextWrapping = TextWrap.WrapWithOverflow
}
}
}
},
new Node()
{
Height = 50,
Width = 50,
LaneOffsetX = 250,
LaneOffsetY = 30
},
}
},
}
};
// Add swimlane
SwimlaneCollections.Add(swimlane);
}

private void OnNodeCreating(IDiagramObject obj)
{
if (obj is Swimlane swimlane)
{
swimlane.Header.Style = new TextStyle()
{
Fill = "#5b9bd5",
StrokeColor = "#5b9bd5"
};
foreach (Phase phase in swimlane.Phases)
{
phase.Style = new ShapeStyle() { Fill = "#5b9bd5", StrokeColor = "#5b9bd5" };
}
foreach (Lane lane in swimlane.Lanes)
{
lane.Header.Style = new TextStyle() { Fill = "#5b9bd5", StrokeColor = "#5b9bd5" };
}
}
else if (obj is Node node)
{
node.Style = new ShapeStyle()
{
Fill = "#5b9bd5",
StrokeColor = "#5b9bd5"
};
}
}
}

```

The following example demonstrates that a constraint can also be enabled or disabled at runtime, for example, via a button click.

```cshtml
@using Syncfusion.Blazor.Diagram

<button onclick="@AllowDrag">AllowDrag</button>
<SfDiagramComponent Height="600px" Swimlanes="@SwimlaneCollections" NodeCreating="@OnNodeCreating" >
<SnapSettings Constraints="SnapConstraints.None"></SnapSettings>
</SfDiagramComponent>

@code
{
//Define diagram's swimlane collection
DiagramObjectCollection<Swimlane> SwimlaneCollections = new DiagramObjectCollection<Swimlane>();

protected override void OnInitialized()
{
// A swimlane is created and stored in the swimlanes collection.
Swimlane swimlane = new Swimlane()
{
Header = new SwimlaneHeader()
{
Annotation = new ShapeAnnotation()
{
Content = "SALES PROCESS FLOW CHART"
},
Height = 50,
},
OffsetX = 400,
OffsetY = 200,
Height = 120,
Width = 450,
Lanes = new DiagramObjectCollection<Lane>()
{
new Lane()
{
Height = 100,
Header = new SwimlaneHeader()
{
Width = 30,
Annotation = new ShapeAnnotation(){ Content = "Consumer" }
},
Children = new DiagramObjectCollection<Node>()
{
new Node()
{
Height = 50,
Width = 100,
LaneOffsetX = 250,
LaneOffsetY = 30
},
}
},
}
};
// Add swimlane
SwimlaneCollections.Add(swimlane);
}

public void AllowDrag()
{
if (diagramComponent.SelectionSettings.Nodes.Count > 0)
{
if (diagramComponent.SelectionSettings.Nodes[0].Constraints.HasFlag(NodeConstraints.AllowDragWithinSwimlane))
{
diagramComponent.SelectionSettings.Nodes[0].Constraints &= ~NodeConstraints.AllowDragWithinSwimlane;

}
else
{
diagramComponent.SelectionSettings.Nodes[0].Constraints |= NodeConstraints.AllowDragWithinSwimlane;
}
}
}
}

```

{% 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)" %}

A complete working sample can be downloaded from [GitHub](https://github.com/SyncfusionExamples/Blazor-Diagram-Examples/tree/master/UG-Samples/Swimlanes/Lane/AllowDragWithinSwimlane/AllowDragWithinSwimlane)