MindFusion.Charting for JavaScript Programmer's Guide
ObservableCollection.insert Method
See Also
 






Adds an item to the collection at the specified index.

Namespace: MindFusion.Common.Collections
File: ObservableCollection.js

 Syntax

JavaScript  Copy Code

function insert (index, item)

 Parameters

index

Type: Number
Number. The index.

item

Type: Object
Object. The object to add.

 Example

The following code creates a List with products. Then it adds several products to it and inserts one at the beginning of the List. List derives from ObservableCollection.

JavaScript  Copy Code

var product1 = new Object();
product1.title = "Ford";
product1.price = 25345;

var product2 = new Object();
product1.title = "BMW";
product1.price = 75300;
......
.....

List products = new List();
products.add(product1);
products.add(product2);


List products = new List([product1, product2, ...]);
.....
.....

if(products.count() > 100)
   products.insert(0, newProduct);

 See Also

ObservableCollection Members
ObservableCollection Class
MindFusion.Common.Collections Namespace