Explicit grouping in BpmnGroup

Dear Syncfusion-Team,

is there a way to change the behaviour of the BpmnGroup from implicit to explicit grouping or no grouping at all?

Currently, whenever I drag a BpmnGroup over another BpmnGroup, it automatically adds one to the other groups' children, bonding them together and resulting in strange behaviour even after dragging it out again.

We would like to explicitly group them together via command (like having a lock symbol). The explicit grouping command is not part of this question, it is about "disabling" the auto-grouping of BpmnGroups/BpmnNodes. We are using BpmnGroups because of the custom layouting features (resizing, dragging), which are not possible with Group.


What I have tried so far:
- using a Group instead of a BpmnGroup (with custom style). This results in inability to drag and resize the group. With some work I managed to get dragging to work but resizing only in lower-right boundaries, as the offsets would not be updated on upper-left thumb resize events. It also seemed very hacky.

- reacting to the OnPropertyChange-Event in the BpmnGroupViewModel to reset the ParentGroup to null. This results in a null-reference-exception in some syncfusion-follow-up code


Best regards

Mario


3 Replies

AK Arun Kumar Sivakumar Syncfusion Team May 30, 2024 03:13 PM UTC

Hi Mario,


Requirement: How can BPMN nodes or BPMN Groups be restricted from being added to the BPMN Group?


We have achieved your requirement in our SfDiagram Control, using the ItemDrop Event. In this ItemDrop Event, we have restricted the BPMN Node or BPMN Group drop based on the necessary conditions. We can enable and disable the grouping behavior by clicking a button. We have provided the code snippet and sample for your reference.


// Here diagram is the instance of the SfDiagram

 (diagram.Info as IGraphInfo).ItemDropEvent += MainWindow_ItemDropEvent;

 

 private void MainWindow_ItemDropEvent(object sender, ItemDropEventArgs args)

 {

     if (!(args.Target is SfDiagram))

     {

         foreach (var Item in args.Target as IEnumerable<object>)

         {

             if (Restrict == true)

             {

                 //To restrict BPMN Nodes, BPMN Connectors and BPMN Groups.

                 if (Item is BpmnGroupViewModel)

                 {

                     args.Cancel = true;

                 }

 

                 // This condition for restrict the BpmnGroup Alone

                 //if (Item is BpmnGroupViewModel && args.Source is BpmnGroupViewModel)

                 //{

                 //    args.Cancel = true;

                 //}

             }

         }

     }

 }

 


Regards,

Arun Kumar S


Attachment: StencilSample_6a6c2119.zip


MV Mario Vielitz May 31, 2024 05:03 AM UTC

Hi Arun,

thank you for the example. It worked like a charm! I also removed the BpmnGroupDropIndicatorStyle from the Diagram as well.


Here is my final code:

private static void DisableBpmnGrouping(object sender, ItemDropEventArgs args)
{
if (args.Source is not BpmnGroupViewModel ||
args.Target is not IEnumerable<object> targetObjects)
return;

args.Cancel = targetObjects.Any(x => x is BpmnGroupViewModel);
}


Best regards

Mario



AK Arun Kumar Sivakumar Syncfusion Team May 31, 2024 09:04 AM UTC

Hi Mario,

 

Thanks for the update. Please let us know if you need further assistance. As always, we are happy to help you out.

 

Regards,

Arun Kumar S



Loader.
Up arrow icon