ASP.NET Pack Programmer's Guide
Events.containerChildAdding Field
See Also
 





A validation event raised to let you prevent users from adding child nodes to a container.

Namespace: MindFusion.Diagramming
Package: Events.js

 Syntax

JavaScript  Copy Code

var containerChildAdding

 Remarks

Call getNode and getContainer methods of the provided NodeEventArgs instance to access the relevant nodes. Set the Cancel argument to true to display the stop cursor and indicate that releasing the mouse button at the current position will cancel the operation.

 Example

This example prevents creating more than two levels of nested containers:

JavaScript  Copy Code

function onContainerChildAdding(sender, args)
{
    var ctr = args.getContainer();

    // prevent third level nested containers

    // do not allow dropping container into an already nested container
    if (args.getNode().children && ctr.getContainer())
    {
        args.setCancel(true);
        args.setHandled(true);
    }

    // do not allow dropping parent of nested containers into a container
    if (args.getNode().children)
    {
        for (var child of args.getNode().children)
        {
            if (child.children)
            {
                args.setCancel(true);
                args.setHandled(true);
                break;
            }
        }
    }
}

 See Also

Events Members
Events Class
MindFusion.Diagramming Namespace
containerChildAdded Event
containerChildRemoving Event