Search
IEnumerable.insert Method
See Also
 






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

Number. The index.

item

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