collectionChanged Event

Summary

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

Syntax
TypeScript
JavaScript
Object.defineProperty(LeadCollection.prototype,'collectionChanged',  
	get: function(), 
	set: function(value) 
) 
collectionChanged: LeadEvent; 
Event Data
ParameterTypeDescription
sendervarThe source of the event.
e

NotifyLeadCollectionChangedEventArgs

The event data.
Remarks

See NotifyLeadCollectionChangedEventArgs for more information on the content of changes.

When checking for changes in CollectionChanged, it is better practice to check the values of NotifyLeadCollectionChangedEventArgs.OldItems and NotifyLeadCollectionChangedEventArgs.NewItems than NotifyLeadCollectionChangedEventArgs.Action, to prevent cases where a NotifyLeadCollectionChangedAction case is missed or incorrectly handled. See below for an example:

function collectionChanged(sender, args) { 
   // Optionally, surround the code below in an if-statement like: 
   //    if (args.action !== lt.NotifyLeadCollectionChangedAction.move) { ... } 
   // since sometimes we don't need to do anything if the item is removed 
   // and then added back in a different spot. 
 
   // Check for removed items first to do some clean-up 
   if (args.oldItems.length > 0) { 
      // Do some setup, if necessary... 
 
      // Loop and do work 
      for (var i = 0; i < args.oldItems.length; i++) { 
         doRemovedItem(args.oldItems[i]); 
      } 
   } 
 
   // Now check for added items 
   if (args.newItems.length > 0) { 
      // Do some setup, if necessary... 
 
      // Loop and do work 
      for (var i = 0; i < args.newItems.length; i++) { 
         doAddedItem(args.newItems[i]); 
      } 
   } 
} 
Requirements

Target Platforms

Help Version 23.0.2024.2.29
Products | Support | Contact Us | Intellectual Property Notices
© 1991-2024 LEAD Technologies, Inc. All Rights Reserved.

Leadtools Assembly
Products | Support | Contact Us | Intellectual Property Notices
© 1991-2023 LEAD Technologies, Inc. All Rights Reserved.