ASP.NET Pack Programmer's Guide
ObservableCollection.collectionChanging Event
See Also
 





Occurs just before an item is added, removed, changed, moved, or the entire list is refreshed.

Namespace: MindFusion.Mapping
Package: ObservableCollection.js

 Syntax

JavaScript  Copy Code

EventDispatcher collectionChanging

 Event Data

The event handler method receives the following arguments:
sender
An ObservableCollection instance, which is the source of the event. This object will be passed to the handler function as the first argument.
args
A NotifyCollectionChangingEventArgs instance, which contains event data. This object will be passed to the handler function as the second argument.

 Example

The following code creates a new DecorationLayer and adds a new Marker to the decorations property. Then it handles the collectionChanging event. It checks if the user is trying to add a new item to the collection and if so - cancels the action. The decorations property is of type ObservableCollection.

JavaScript  Copy Code

var m = MindFusion.Mapping;

var markers = new m.DecorationLayer("Images");

// create some markers with images
var mark = new m.Marker(new m.LatLong(-22.951916, -43.210487));
mark.imageSrc = "./images/christ_redeemer.png";
mark.text = "Christ the Redeemer";
markers.decorations.add(mark);


markers.decorations.collectionChanging.addEventListener(handleCollectionChanging);


function (handleCollectionChanging) (sender, args )
{
     if(args.action == m.NotifyCollectionChangedAction.Add)
     {
          args.cancel = true;
     }
}

 See Also

ObservableCollection Members
ObservableCollection Class
MindFusion.Mapping Namespace