DataGrid.addColumnAt()

Availability

Flash Player 6 (6.0.79.0).

Edition

Flash MX Professional 2004.

Usage

myDataGrid.addColumnAt(index, name)
myDataGrid.addColumnAt(index, dataGridColumn)

Parameters

index The index position at which the DataGridColumn object is added. The first position is 0.

name A string that indicates the name of the DataGridColumn object.

dataGridColumn An instance of the DataGridColumn class.

Returns

A reference to the DataGridColumn object that was added, or returns the string that indicates the name of the new column.

Description

Method; adds a new column at the specified position. Columns are shifted to the right and their indexes are incremented. For more information, see DataGridColumn class.

Example

This example shows two ways to use addColumnAt() and sets the column widths. With a DataGrid instance named my_dg on the Stage, paste the following code in the first frame of the main timeline (notice that it imports the DataGridColumn class first):

import mx.controls.gridclasses.DataGridColumn;

var my_dg:mx.controls.DataGrid;
my_dg.setSize(320, 240);

// Add columns to grid.
my_dg.addColumnAt(0, "Orange");
var orange_dgc:DataGridColumn = my_dg.getColumnAt(0);
orange_dgc.width = 125;

var blue_dgc:DataGridColumn = new DataGridColumn("Blue");
blue_dgc.width = 75;
my_dg.addColumnAt(1, blue_dgc);