MindFusion.Charting for JavaScript Programmer's Guide
IEnumerable.insert Method
See Also
Collapse All Expand All Language Filter: All Language Filter: Multiple Language Filter: None Language Filter: C# Language Filter: Visual Basic Language Filter: Java Language Filter: JavaScript Language Filter: C++ Language Filter: XAML

C#
Visual Basic
Java
JavaScript
C++
XAML

Adds an element to the collection at the specified index.

Namespace: MindFusion.Common.Collections
File: IEnumerable.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 inserts a TreeNode at the second position among the items of a TreeView root:

JavaScript Copy Code
var treeView = new ui.TreeView(document.getElementById("treeView")); treeView.width = treeView.height = ui.Unit.percentage(100); treeView.theme = "standard"; treeView.loadOnDemand = true; // create a tree node that will be a root in our hierarchy var root = new ui.TreeNode("body"); root.expanded = true; var span = new ui.TreeNode("span"); var div = new ui.TreeNode("div"); var p = new ui.TreeNode("p"); var elements = [span, div, p]; root.items.addRange(elements); var block = new ui.TreeNode("block"); root.items.insert(block, 1);

## See Also

IEnumerable Members
IEnumerable Class
MindFusion.Common.Collections Namespace