DataGrid.addItemAt()

Availability

Flash Player 6 (6.0.79.0).

Edition

Flash MX Professional 2004.

Usage

myDataGrid.addItemAt(index, item)

Parameters

index The index position (among the child nodes) at which the node should be added. The first position is 0.

item A string that displays the node.

Returns

A reference to the object instance that was added.

Description

Method; adds an item to the grid at the position specified.

Example

This example creates one column with the heading "name", populates the column from an array, and then adds the name "Chase" in the first row. Notice that the "age" value is ignored, because only the name column has been defined. If you don't specify a column (remove the addColumn line), DataGrid automatically creates the appropriate columns. With a DataGrid instance named my_dg on the Stage, paste the following code in the first frame of the main timeline:

var my_dg:mx.controls.DataGrid;

// Add columns to grid and add data.
my_dg.addColumn("name");

var myDP_array:Array = new Array({name:"John", age:33}, {name:"Jose", age:41});
my_dg.dataProvider = myDP_array;

var item_obj:Object = {name:"Chase", age:30};
my_dg.addItemAt(0, item_obj);