ActionScript® 3.0 Reference for the Adobe® Flash® Platform
Home  |  Show Packages and Classes List |  Packages  |  Classes  |  What's New  |  Index  |  Appendixes
fl.controls 

DataGrid  - AS3 Flash

Packagefl.controls
Classpublic class DataGrid
InheritanceDataGrid Inheritance SelectableList Inheritance BaseScrollPane Inheritance UIComponent Inheritance Sprite Inheritance DisplayObjectContainer Inheritance InteractiveObject Inheritance DisplayObject Inheritance EventDispatcher Inheritance Object
Implements IFocusManagerComponent

Language Version: ActionScript 3.0
Product Version: Flash CS3
Runtime Versions: Flash Player 9.0.28.0, AIR 1.0

The DataGrid class is a list-based component that provides a grid of rows and columns. You can specify an optional header row at the top of the component that shows all the property names. Each row consists of one or more columns, each of which represents a property that belongs to the specified data object. The DataGrid component is used to view data; it is not intended to be used as a layout tool like an HTML table.

A DataGrid component is well suited for the display of objects that contain multiple properties. The data that a DataGrid component displays can be contained in a DataProvider object or as an array of objects. The columns of a DataGrid component can be represented by a list of DataGridColumn objects, each of which contains information that is specific to the column.

The DataGrid component provides the following features:

  • Columns of different widths or identical fixed widths
  • Columns that the user can resize at run time
  • Columns that the user can reorder at run time by using ActionScript
  • Optional customizable column headers
  • Support for custom item renderers to display data other than text in any column
  • Support for sorting data by clicking on the column that contains it

The DataGrid component is composed of subcomponents including ScrollBar, HeaderRenderer, CellRenderer, DataGridCellEditor, and ColumnDivider components, all of which can be skinned during authoring or at run time.

The DataGrid component uses the following classes that can be found in the dataGridClasses package:

  • DataGridColumn: Describes a column in a DataGrid component. Contains the indexes, widths, and other properties of the column. Does not contain cell data.
  • HeaderRenderer: Displays the column header for the current DataGrid column. Contains the label and other properties of the column header.
  • DataGridCellEditor: Manages the editing of the data for each cell.

View the examples

Related API Elements



Public Properties
 PropertyDefined By
 InheritedaccessibilityImplementation : AccessibilityImplementation
The current accessibility implementation (AccessibilityImplementation) for this InteractiveObject instance.
InteractiveObject
 InheritedaccessibilityProperties : AccessibilityProperties
The current accessibility options for this display object.
DisplayObject
 InheritedallowMultipleSelection : Boolean
Gets a Boolean value that indicates whether more than one list item can be selected at a time.
SelectableList
 Inheritedalpha : Number
Indicates the alpha transparency value of the object specified.
DisplayObject
 InheritedblendMode : String
A value from the BlendMode class that specifies which blend mode to use.
DisplayObject
 InheritedblendShader : Shader
[write-only] Sets a shader that is used for blending the foreground and background.
DisplayObject
 InheritedbuttonMode : Boolean
Specifies the button mode of this sprite.
Sprite
 InheritedcacheAsBitmap : Boolean
If set to true, Flash runtimes cache an internal bitmap representation of the display object.
DisplayObject
 Inherited    cacheAsBitmapMatrix : Matrix
If non-null, this Matrix object defines how a display object is rendered when cacheAsBitmap is set to true.
DisplayObject
  columns : Array
Gets or sets an array of DataGridColumn objects, one for each column that can be displayed.
DataGrid
 Inheritedconstructor : Object
A reference to the class object or constructor function for a given object instance.
Object
 InheritedcontextMenu : NativeMenu
Specifies the context menu associated with this object.
InteractiveObject
 InheriteddataProvider : DataProvider
Gets or sets the data model of the list of items to be viewed.
SelectableList
 InheriteddoubleClickEnabled : Boolean
Specifies whether the object receives doubleClick events.
InteractiveObject
 InheriteddropTarget : DisplayObject
[read-only] Specifies the display object over which the sprite is being dragged, or on which the sprite was dropped.
Sprite
  editable : Boolean = false
Indicates whether or not the user can edit items in the data provider.
DataGrid
  editedItemPosition : Object
Gets or sets the column and row index of the item renderer for the data provider item that is being edited.
DataGrid
  editedItemRenderer : ICellRenderer
[read-only] Gets a reference to the item renderer in the DataGrid component whose item is currently being edited.
DataGrid
 Inheritedenabled : Boolean
Gets or sets a value that indicates whether the component can accept user interaction.
UIComponent
 Inheritedfilters : Array
An indexed array that contains each filter object currently associated with the display object.
DisplayObject
 InheritedfocusEnabled : Boolean
Gets or sets a Boolean value that indicates whether the component can receive focus after the user clicks it.
UIComponent
 InheritedfocusManager : IFocusManager
Gets or sets the FocusManager that controls focus for this component and its peers.
UIComponent
 InheritedfocusRect : Object
Specifies whether this object displays a focus rectangle.
InteractiveObject
 Inheritedgraphics : Graphics
[read-only] Specifies the Graphics object that belongs to this sprite where vector drawing commands can occur.
Sprite
  headerHeight : Number
Gets or sets the height of the DataGrid header, in pixels.
DataGrid
 Inheritedheight : Number
[override] Gets or sets the height of the component, in pixels.
UIComponent
 InheritedhitArea : Sprite
Designates another sprite to serve as the hit area for a sprite.
Sprite
 InheritedhorizontalLineScrollSize : Number
Gets or sets a value that describes the amount of content to be scrolled, horizontally, when a scroll arrow is clicked.
BaseScrollPane
 InheritedhorizontalPageScrollSize : Number
Gets or sets the count of pixels by which to move the scroll thumb on the horizontal scroll bar when the scroll bar track is pressed.
BaseScrollPane
 InheritedhorizontalScrollBar : ScrollBar
[read-only] Gets a reference to the horizontal scroll bar.
BaseScrollPane
  horizontalScrollPolicy : String
[override] Gets or sets a Boolean value that indicates whether the horizontal scroll bar is always on.
DataGrid
 InheritedhorizontalScrollPosition : Number
Gets or sets a value that describes the horizontal position of the horizontal scroll bar in the scroll pane, in pixels.
BaseScrollPane
  imeMode : String
Gets or sets the mode of the input method editor (IME).
DataGrid
  itemEditorInstance : Object
A reference to the currently active instance of the item editor, if one exists.
DataGrid
  labelFunction : Function
Gets or sets a function that determines which fields of each item to use for the label text.
DataGrid
 Inheritedlength : uint
[read-only] Gets the number of items in the data provider.
SelectableList
 InheritedloaderInfo : LoaderInfo
[read-only] Returns a LoaderInfo object containing information about loading the file to which this display object belongs.
DisplayObject
 Inheritedmask : DisplayObject
The calling display object is masked by the specified mask object.
DisplayObject
 InheritedmaxHorizontalScrollPosition : Number
[override] Gets or sets the number of pixels that the list scrolls to the right when the horizontalScrollPolicy property is set to ScrollPolicy.ON.
SelectableList
 InheritedmaxVerticalScrollPosition : Number
[read-only] Gets the maximum vertical scroll position for the current content, in pixels.
BaseScrollPane
 InheritedmetaData : Object
Obtains the meta data object of the DisplayObject instance if meta data was stored alongside the the instance of this DisplayObject in the SWF file through a PlaceObject4 tag.
DisplayObject
  minColumnWidth : Number
Gets or sets the minimum width of a DataGrid column, in pixels.
DataGrid
 InheritedmouseChildren : Boolean
Determines whether or not the children of the object are mouse, or user input device, enabled.
DisplayObjectContainer
 InheritedmouseEnabled : Boolean
Specifies whether this object receives mouse, or other user input, messages.
InteractiveObject
 InheritedmouseFocusEnabled : Boolean
Gets or sets a value that indicates whether the component can receive focus after the user clicks it.
UIComponent
 InheritedmouseX : Number
[read-only] Indicates the x coordinate of the mouse or user input device position, in pixels.
DisplayObject
 InheritedmouseY : Number
[read-only] Indicates the y coordinate of the mouse or user input device position, in pixels.
DisplayObject
 Inheritedname : String
Indicates the instance name of the DisplayObject.
DisplayObject
 InheritedneedsSoftKeyboard : Boolean
Specifies whether a virtual keyboard (an on-screen, software keyboard) should display when this InteractiveObject instance receives focus.
InteractiveObject
 InheritednumChildren : int
[read-only] Returns the number of children of this object.
DisplayObjectContainer
 InheritedopaqueBackground : Object
Specifies whether the display object is opaque with a certain background color.
DisplayObject
 Inheritedparent : DisplayObjectContainer
[read-only] Indicates the DisplayObjectContainer object that contains this display object.
DisplayObject
  resizableColumns : Boolean = true
Indicates whether the user can change the size of the columns.
DataGrid
 Inheritedroot : DisplayObject
[read-only] For a display object in a loaded SWF file, the root property is the top-most display object in the portion of the display list's tree structure represented by that SWF file.
DisplayObject
 Inheritedrotation : Number
Indicates the rotation of the DisplayObject instance, in degrees, from its original orientation.
DisplayObject
 InheritedrotationX : Number
Indicates the x-axis rotation of the DisplayObject instance, in degrees, from its original orientation relative to the 3D parent container.
DisplayObject
 InheritedrotationY : Number
Indicates the y-axis rotation of the DisplayObject instance, in degrees, from its original orientation relative to the 3D parent container.
DisplayObject
 InheritedrotationZ : Number
Indicates the z-axis rotation of the DisplayObject instance, in degrees, from its original orientation relative to the 3D parent container.
DisplayObject
  rowCount : uint
[override] Gets or sets the number of rows that are at least partially visible in the list.
DataGrid
  rowHeight : Number
Gets or sets the height of each row in the DataGrid component, in pixels.
DataGrid
 Inheritedscale9Grid : Rectangle
The current scaling grid that is in effect.
DisplayObject
 InheritedscaleX : Number
[override] Multiplies the current width of the component by a scale factor.
UIComponent
 InheritedscaleY : Number
[override] Multiplies the current height of the component by a scale factor.
UIComponent
 InheritedscaleZ : Number
Indicates the depth scale (percentage) of an object as applied from the registration point of the object.
DisplayObject
 InheritedscrollRect : Rectangle
The scroll rectangle bounds of the display object.
DisplayObject
 Inheritedselectable : Boolean
Gets or sets a Boolean value that indicates whether the items in the list can be selected.
SelectableList
 InheritedselectedIndex : int
Gets or sets the index of the item that is selected in a single-selection list.
SelectableList
 InheritedselectedIndices : Array
Gets or sets an array that contains the items that were selected from a multiple-selection list.
SelectableList
 InheritedselectedItem : Object
Gets or sets the item that was selected from a single-selection list.
SelectableList
 InheritedselectedItems : Array
Gets or sets an array that contains the objects for the items that were selected from the multiple-selection list.
SelectableList
  showHeaders : Boolean
Gets or sets a Boolean value that indicates whether the DataGrid component shows column headers.
DataGrid
 InheritedsoftKeyboardInputAreaOfInterest : Rectangle
Defines the area that should remain on-screen when a soft keyboard is displayed (not available on iOS).
InteractiveObject
  sortableColumns : Boolean = true
Indicates whether the user can sort the items in the data provider by clicking on a column header cell.
DataGrid
  sortDescending : Boolean
[read-only] Gets the order in which a column is sorted when the user clicks its header.
DataGrid
  sortIndex : int
[read-only] Gets the index of the column to be sorted.
DataGrid
 InheritedsoundTransform : flash.media:SoundTransform
Controls sound within this sprite.
Sprite
 Inheritedstage : Stage
[read-only] The Stage of the display object.
DisplayObject
 InheritedtabChildren : Boolean
Determines whether the children of the object are tab enabled.
DisplayObjectContainer
 InheritedtabEnabled : Boolean
Specifies whether this object is in the tab order.
InteractiveObject
 InheritedtabIndex : int
Specifies the tab ordering of objects in a SWF file.
InteractiveObject
 InheritedtextSnapshot : flash.text:TextSnapshot
[read-only] Returns a TextSnapshot object for this DisplayObjectContainer instance.
DisplayObjectContainer
 Inheritedtransform : flash.geom:Transform
An object with properties pertaining to a display object's matrix, color transform, and pixel bounds.
DisplayObject
 InheriteduseBitmapScrolling : Boolean
When set to true, the cacheAsBitmap property for the scrolling content is set to true; when set to false this value is turned off.
BaseScrollPane
 InheriteduseHandCursor : Boolean
A Boolean value that indicates whether the pointing hand (hand cursor) appears when the pointer rolls over a sprite in which the buttonMode property is set to true.
Sprite
 InheritedverticalLineScrollSize : Number
Gets or sets a value that describes how many pixels to scroll vertically when a scroll arrow is clicked.
BaseScrollPane
 InheritedverticalPageScrollSize : Number
Gets or sets the count of pixels by which to move the scroll thumb on the vertical scroll bar when the scroll bar track is pressed.
BaseScrollPane
 InheritedverticalScrollBar : ScrollBar
[read-only] Gets a reference to the vertical scroll bar.
BaseScrollPane
 InheritedverticalScrollPolicy : String
Gets or sets a value that indicates the state of the vertical scroll bar.
BaseScrollPane
 InheritedverticalScrollPosition : Number
Gets or sets a value that describes the vertical position of the vertical scroll bar in the scroll pane, in pixels.
BaseScrollPane
 Inheritedvisible : Boolean
[override] Gets or sets a value that indicates whether the current component instance is visible.
UIComponent
 Inheritedwidth : Number
[override] Gets or sets the width of the component, in pixels.
UIComponent
 Inheritedx : Number
[override] Gets or sets the x coordinate that represents the position of the component along the x axis within its parent container.
UIComponent
 Inheritedy : Number
[override] Gets or sets the y coordinate that represents the position of the component along the y axis within its parent container.
UIComponent
 Inheritedz : Number
Indicates the z coordinate position along the z-axis of the DisplayObject instance relative to the 3D parent container.
DisplayObject
Public Methods
 MethodDefined By
  
Creates a new DataGrid component instance.
DataGrid
 Inherited
Adds a child DisplayObject instance to this DisplayObjectContainer instance.
DisplayObjectContainer
 Inherited
Adds a child DisplayObject instance to this DisplayObjectContainer instance.
DisplayObjectContainer
  
Adds a column to the end of the columns array.
DataGrid
  
Inserts a column at the specified index in the columns array.
DataGrid
 Inherited
addEventListener(type:String, listener:Function, useCapture:Boolean = false, priority:int = 0, useWeakReference:Boolean = false):void
Registers an event listener object with an EventDispatcher object so that the listener receives notification of an event.
EventDispatcher
 Inherited
Appends an item to the end of the list of items.
SelectableList
 Inherited
addItemAt(item:Object, index:uint):void
Inserts an item into the list at the specified index location.
SelectableList
 Inherited
Indicates whether the security restrictions would cause any display objects to be omitted from the list returned by calling the DisplayObjectContainer.getObjectsUnderPoint() method with the specified point point.
DisplayObjectContainer
 Inherited
clearRendererStyle(name:String, column:int = -1):void
Clears a style that is set on the renderers in the list.
SelectableList
 Inherited
Clears the currently selected item in the list and sets the selectedIndex property to -1.
SelectableList
 Inherited
Deletes a style property from this component instance.
UIComponent
 Inherited
Determines whether the specified display object is a child of the DisplayObjectContainer instance or the instance itself.
DisplayObjectContainer
  
createItemEditor(colIndex:uint, rowIndex:uint):void
Uses the editor specified by the itemEditor property to create an item editor for the item renderer at the column and row index identified by the editedItemPosition property.
DataGrid
  
Closes an item editor that is currently open on an item renderer.
DataGrid
 Inherited
Dispatches an event into the event flow.
EventDispatcher
 Inherited
Shows or hides the focus indicator on this component.
UIComponent
 Inherited
Initiates an immediate draw operation, without invalidating everything as invalidateNow does.
UIComponent
  
editField(index:uint, dataField:String, data:Object):void
Edits a given field or property in the DataGrid component.
DataGrid
 Inherited
getBounds(targetCoordinateSpace:DisplayObject):Rectangle
Returns a rectangle that defines the area of the display object relative to the coordinate system of the targetCoordinateSpace object.
DisplayObject
  
Get the instance of a cell renderer at the specified position in the DataGrid.
DataGrid
 Inherited
Returns the child display object instance that exists at the specified index.
DisplayObjectContainer
 Inherited
Returns the child display object that exists with the specified name.
DisplayObjectContainer
 Inherited
Returns the index position of a child DisplayObject instance.
DisplayObjectContainer
  
Retrieves the column that is located at the specified index of the columns array.
DataGrid
  
Retrieves the number of columns in the DataGrid component.
DataGrid
  
Retrieves the index of the column of the specified name, or -1 if no match is found.
DataGrid
 Inherited
Retrieves the object that currently has focus.
UIComponent
 Inherited
Retrieves the item at the specified index.
SelectableList
 Inherited
getNextIndexAtLetter(firstLetter:String, startIndex:int = -1):int
Returns the index of the next item in the dataProvider in which the label's first character matches a specified string character.
SelectableList
 Inherited
Returns an array of objects that lie under the specified point and are children (or grandchildren, and so on) of this DisplayObjectContainer instance.
DisplayObjectContainer
 Inherited
getRect(targetCoordinateSpace:DisplayObject):Rectangle
Returns a rectangle that defines the boundary of the display object, based on the coordinate system defined by the targetCoordinateSpace parameter, excluding any strokes on shapes.
DisplayObject
 Inherited
getRendererStyle(name:String, column:int = -1):Object
Retrieves a style that is set on the renderers in the list.
SelectableList
 Inherited
Retrieves a style property that is set in the style lookup chain of the component.
UIComponent
  
[static] Retrieves the default style map for the current component.
DataGrid
 Inherited
Converts the point object from the Stage (global) coordinates to the display object's (local) coordinates.
DisplayObject
 Inherited
Converts a two-dimensional point from the Stage (global) coordinates to a three-dimensional display object's (local) coordinates.
DisplayObject
 Inherited
Checks whether the EventDispatcher object has any listeners registered for a specific type of event.
EventDispatcher
 Inherited
Indicates whether an object has a specified property defined.
Object
 Inherited
Evaluates the bounding box of the display object to see if it overlaps or intersects with the bounding box of the obj display object.
DisplayObject
 Inherited
hitTestPoint(x:Number, y:Number, shapeFlag:Boolean = false):Boolean
Evaluates the display object to see if it overlaps or intersects with the point specified by the x and y parameters.
DisplayObject
 Inherited
invalidate(property:String, callLater:Boolean = true):void
Marks a property as invalid and redraws the component on the next frame unless otherwise specified.
UIComponent
 Inherited
Invalidates a specific item renderer.
SelectableList
 Inherited
Invalidates the renderer for the item at the specified index.
SelectableList
 Inherited
Invalidates the whole list, forcing the list items to be redrawn.
SelectableList
 Inherited
Checks whether the specified item is selected in the list.
SelectableList
 Inherited
Indicates whether an instance of the Object class is in the prototype chain of the object specified as the parameter.
Object
  
[override] The DataGrid component has multiple cells for any given item, so the itemToCellRenderer method always returns null.
DataGrid
 Inherited
Retrieves the string that the renderer displays for the given data object based on the label properties of the object.
SelectableList
 Inherited
Converts a three-dimensional point of the three-dimensional display object's (local) coordinates to a two-dimensional point in the Stage (global) coordinates.
DisplayObject
 Inherited
Converts the point object from the display object's (local) coordinates to the Stage (global) coordinates.
DisplayObject
 Inherited
[static] Merges the styles from multiple classes into one object.
UIComponent
 Inherited
Moves the component to the specified position within its parent.
UIComponent
 Inherited
Indicates whether the specified property exists and is enumerable.
Object
 Inherited
Removes all items from the list.
SelectableList
  
Removes all columns from the DataGrid component.
DataGrid
 Inherited
Removes the specified child DisplayObject instance from the child list of the DisplayObjectContainer instance.
DisplayObjectContainer
 Inherited
Removes a child DisplayObject from the specified index position in the child list of the DisplayObjectContainer.
DisplayObjectContainer
 Inherited
removeChildren(beginIndex:int = 0, endIndex:int = 0x7fffffff):void
Removes all child DisplayObject instances from the child list of the DisplayObjectContainer instance.
DisplayObjectContainer
  
Removes the column that is located at the specified index of the columns array.
DataGrid
 Inherited
removeEventListener(type:String, listener:Function, useCapture:Boolean = false):void
Removes a listener from the EventDispatcher object.
EventDispatcher
 Inherited
Removes the specified item from the list.
SelectableList
 Inherited
Removes the item at the specified index position.
SelectableList
 Inherited
Replaces the item at the specified index location with another item.
SelectableList
 Inherited
Raises a virtual keyboard.
InteractiveObject
  
scrollToIndex(newCaretIndex:int):void
[override] Scrolls the list to the item at the specified index.
DataGrid
 Inherited
Scrolls the list to the item at the location indicated by the current value of the selectedIndex property.
SelectableList
 Inherited
Changes the position of an existing child in the display object container.
DisplayObjectContainer
 Inherited
Sets the focus to this component.
UIComponent
 Inherited
Sets the availability of a dynamic property for loop operations.
Object
 Inherited
setRendererStyle(name:String, style:Object, column:uint = 0):void
Sets a style on the renderers in the list.
SelectableList
 Inherited
setSize(width:Number, height:Number):void
Sets the component to the specified width and height.
UIComponent
 Inherited
setStyle(style:String, value:Object):void
Sets a style property on this component instance.
UIComponent
 Inherited
sortItems(... sortArgs):*
Sorts the elements of the current data provider.
SelectableList
 Inherited
sortItemsOn(field:String, options:Object = null):*
Sorts the elements of the current data provider by one or more of its fields.
SelectableList
  
Resets the widths of the visible columns to the same size.
DataGrid
 Inherited
startDrag(lockCenter:Boolean = false, bounds:Rectangle = null):void
Lets the user drag the specified sprite.
Sprite
 Inherited
startTouchDrag(touchPointID:int, lockCenter:Boolean = false, bounds:Rectangle = null):void
Lets the user drag the specified sprite on a touch-enabled device.
Sprite
 Inherited
Recursively stops the timeline execution of all MovieClips rooted at this object.
DisplayObjectContainer
 Inherited
Ends the startDrag() method.
Sprite
 Inherited
stopTouchDrag(touchPointID:int):void
Ends the startTouchDrag() method, for use with touch-enabled devices.
Sprite
 Inherited
Swaps the z-order (front-to-back order) of the two specified child objects.
DisplayObjectContainer
 Inherited
swapChildrenAt(index1:int, index2:int):void
Swaps the z-order (front-to-back order) of the child objects at the two specified index positions in the child list.
DisplayObjectContainer
 Inherited
Returns the string representation of this object, formatted according to locale-specific conventions.
Object
 Inherited
Returns the string representation of the specified object.
Object
 Inherited
Validates and updates the properties and layout of this object, redrawing it if necessary.
UIComponent
 Inherited
Returns the primitive value of the specified object.
Object
 Inherited
Checks whether an event listener is registered with this EventDispatcher object or any of its ancestors for the specified event type.
EventDispatcher
Protected Methods
 MethodDefined By
 Inherited
Returns the specified style for a component, considering all styles set on the global level, component level and instance level.
UIComponent
Events
 Event Summary Defined By
 Inherited[broadcast event] Dispatched when the Flash Player or AIR application gains operating system focus and becomes active.EventDispatcher
 InheritedDispatched when a display object is added to the display list.DisplayObject
 InheritedDispatched when a display object is added to the on stage display list, either directly or through the addition of a sub tree in which the display object is contained.DisplayObject
 InheritedDispatched when a different item is selected in the list.SelectableList
 InheritedDispatched when the user selects 'Clear' (or 'Delete') from the text context menu.InteractiveObject
 InheritedDispatched when a user presses and releases the main button of the user's pointing device over the same InteractiveObject.InteractiveObject
  Dispatched after a user expands a column horizontally.DataGrid
 Inherited
    contextMenu
Dispatched when a user gesture triggers the context menu associated with this interactive object in an AIR application.InteractiveObject
 InheritedDispatched when the user activates the platform-specific accelerator key combination for a copy operation or selects 'Copy' from the text context menu.InteractiveObject
 InheritedDispatched when the user activates the platform-specific accelerator key combination for a cut operation or selects 'Cut' from the text context menu.InteractiveObject
 Inherited[broadcast event] Dispatched when the Flash Player or AIR application operating loses system focus and is becoming inactive.EventDispatcher
 InheritedDispatched when a user presses and releases the main button of a pointing device twice in rapid succession over the same InteractiveObject when that object's doubleClickEnabled flag is set to true.InteractiveObject
 Inherited[broadcast event] Dispatched when the playhead is entering a new frame.DisplayObject
 Inherited[broadcast event] Dispatched when the playhead is exiting the current frame.DisplayObject
 InheritedDispatched after a display object gains focus.InteractiveObject
 InheritedDispatched after a display object loses focus.InteractiveObject
 Inherited[broadcast event] Dispatched after the constructors of frame display objects have run but before frame scripts have run.DisplayObject
 InheritedDispatched when the user presses two points of contact over the same InteractiveObject instance on a touch-enabled device (such as presses and releases two fingers over a display object on a mobile phone or tablet with a touch screen).InteractiveObject
 InheritedDispatched when the user moves a point of contact over the InteractiveObject instance on a touch-enabled device (such as moving a finger from left to right over a display object on a mobile phone or tablet with a touch screen).InteractiveObject
 InheritedDispatched when the user performs a rotation gesture at a point of contact with an InteractiveObject instance (such as touching two fingers and rotating them over a display object on a mobile phone or tablet with a touch screen).InteractiveObject
 InheritedDispatched when the user performs a swipe gesture at a point of contact with an InteractiveObject instance (such as touching three fingers to a screen and then moving them in parallel over a display object on a mobile phone or tablet with a touch screen).InteractiveObject
 InheritedDispatched when the user creates a point of contact with an InteractiveObject instance, then taps on a touch-enabled device (such as placing several fingers over a display object to open a menu and then taps one finger to select a menu item on a mobile phone or tablet with a touch screen).InteractiveObject
 InheritedDispatched when the user performs a zoom gesture at a point of contact with an InteractiveObject instance (such as touching two fingers to a screen and then quickly spreading the fingers apart over a display object on a mobile phone or tablet with a touch screen).InteractiveObject
  Dispatched after the user clicks a header cell.DataGrid
 InheritedDispatched after the component visibility changes from visible to invisible.UIComponent
 InheritedThis event is dispatched to any client app that supports inline input with an IMEInteractiveObject
 InheritedDispatched when the user clicks an item in the component.SelectableList
 InheritedDispatched when the user clicks an item in the component twice in rapid succession.SelectableList
  Dispatched after the editedItemPosition property is set and the item can be edited.DataGrid
  Dispatched after a user prepares to edit an item, for example, by releasing the mouse button over the item.DataGrid
  Dispatched when an item editing session ends for any reason.DataGrid
  Dispatched after an item receives focus.DataGrid
  Dispatched after an item loses focus.DataGrid
 InheritedDispatched when the user rolls the pointer off of an item in the component.SelectableList
 InheritedDispatched when the user rolls the pointer over an item in the component.SelectableList
 InheritedDispatched when the user presses a key.InteractiveObject
 InheritedDispatched when the user attempts to change focus by using keyboard navigation.InteractiveObject
 InheritedDispatched when the user releases a key.InteractiveObject
 InheritedDispatched when a user presses and releases the middle button of the user's pointing device over the same InteractiveObject.InteractiveObject
 InheritedDispatched when a user presses the middle pointing device button over an InteractiveObject instance.InteractiveObject
 InheritedDispatched when a user releases the pointing device button over an InteractiveObject instance.InteractiveObject
 InheritedDispatched when a user presses the pointing device button over an InteractiveObject instance.InteractiveObject
 InheritedDispatched when the user attempts to change focus by using a pointer device.InteractiveObject
 InheritedDispatched when a user moves the pointing device while it is over an InteractiveObject.InteractiveObject
 InheritedDispatched when the user moves a pointing device away from an InteractiveObject instance.InteractiveObject
 InheritedDispatched when the user moves a pointing device over an InteractiveObject instance.InteractiveObject
 InheritedDispatched when a user releases the pointing device button over an InteractiveObject instance.InteractiveObject
 InheritedDispatched when a mouse wheel is spun over an InteractiveObject instance.InteractiveObject
 InheritedDispatched after the component is moved.UIComponent
 InheritedDispatched by the drag initiator InteractiveObject when the user releases the drag gesture.InteractiveObject
 InheritedDispatched by the target InteractiveObject when a dragged object is dropped on it and the drop has been accepted with a call to DragManager.acceptDragDrop().InteractiveObject
 InheritedDispatched by an InteractiveObject when a drag gesture enters its boundary.InteractiveObject
 InheritedDispatched by an InteractiveObject when a drag gesture leaves its boundary.InteractiveObject
 InheritedDispatched by an InteractiveObject continually while a drag gesture remains within its boundary.InteractiveObject
 InheritedDispatched at the beginning of a drag operation by the InteractiveObject that is specified as the drag initiator in the DragManager.doDrag() call.InteractiveObject
 InheritedDispatched during a drag operation by the InteractiveObject that is specified as the drag initiator in the DragManager.doDrag() call.InteractiveObject
 InheritedDispatched when the user activates the platform-specific accelerator key combination for a paste operation or selects 'Paste' from the text context menu.InteractiveObject
 InheritedDispatched when the user lowers an active stylus past the proximity detection threshold of the screen.InteractiveObject
 Inherited
    proximityEnd
Dispatched when the user lifts an active stylus above the proximity detection threshold of the screen.InteractiveObject
 InheritedDispatched when the user moves an active stylus over the screen while remaining within the proximity detection threshold.InteractiveObject
 Inherited
    proximityOut
Dispatched when the user moves an active stylus away from this InteractiveObject while remaining within the proximity detection threshold of the screen.InteractiveObject
 InheritedDispatched when the user moves an active stylus directly above this InteractiveObject while remaining within the proximity detection threshold of the screen.InteractiveObject
 InheritedDispatched when the user moves an active stylus away from this InteractiveObject and any of its children while remaining within the proximity detection threshold of the screen.InteractiveObject
 InheritedDispatched when the user moves an active stylus over this InteractiveObject from outside the object's tree of descendents in the display list (while remaining within the proximity detection threshold of the screen).InteractiveObject
 InheritedDispatched when a user releases the button on the pointing device after the user first pressed the button over an InteractiveObject instance and then moved the pointing device off of the InteractiveObject instance.InteractiveObject
 InheritedDispatched when a display object is about to be removed from the display list.DisplayObject
 InheritedDispatched when a display object is about to be removed from the display list, either directly or through the removal of a sub tree in which the display object is contained.DisplayObject
 Inherited[broadcast event] Dispatched when the display list is about to be updated and rendered.DisplayObject
 InheritedDispatched after the component is resized.UIComponent
 InheritedDispatched when a user presses and releases the right button of the user's pointing device over the same InteractiveObject.InteractiveObject
 InheritedDispatched when a user presses the pointing device button over an InteractiveObject instance.InteractiveObject
 InheritedDispatched when a user releases the pointing device button over an InteractiveObject instance.InteractiveObject
 InheritedDispatched when the user rolls the pointer off of the component.SelectableList
 InheritedDispatched when the user rolls the pointer over the component.SelectableList
 InheritedDispatched when the user scrolls horizontally or vertically.SelectableList
 InheritedDispatched when the user activates the platform-specific accelerator key combination for a select all operation or selects 'Select All' from the text context menu.InteractiveObject
 InheritedDispatched after the component visibility changes from invisible to visible.UIComponent
 InheritedDispatched immediately after the soft keyboard is raised.InteractiveObject
 InheritedDispatched immediately before the soft keyboard is raised.InteractiveObject
 InheritedDispatched immediately after the soft keyboard is lowered.InteractiveObject
 InheritedDispatched when the value of the object's tabChildren flag changes.InteractiveObject
 InheritedDispatched when the object's tabEnabled flag changes.InteractiveObject
 InheritedDispatched when the value of the object's tabIndex property changes.InteractiveObject
 InheritedDispatched when a user enters one or more characters of text.InteractiveObject
 InheritedDispatched when the user first contacts a touch-enabled device (such as touches a finger to a mobile phone or tablet with a touch screen).InteractiveObject
 InheritedDispatched when the user removes contact with a touch-enabled device (such as lifts a finger off a mobile phone or tablet with a touch screen).InteractiveObject
 InheritedDispatched when the user touches the device, and is continuously dispatched until the point of contact is removed.InteractiveObject
 InheritedDispatched when the user moves the point of contact away from InteractiveObject instance on a touch-enabled device (such as drags a finger from one display object to another on a mobile phone or tablet with a touch screen).InteractiveObject
 InheritedDispatched when the user moves the point of contact over an InteractiveObject instance on a touch-enabled device (such as drags a finger from a point outside a display object to a point over a display object on a mobile phone or tablet with a touch screen).InteractiveObject
 InheritedDispatched when the user moves the point of contact away from an InteractiveObject instance on a touch-enabled device (such as drags a finger from over a display object to a point outside the display object on a mobile phone or tablet with a touch screen).InteractiveObject
 InheritedDispatched when the user moves the point of contact over an InteractiveObject instance on a touch-enabled device (such as drags a finger from a point outside a display object to a point over a display object on a mobile phone or tablet with a touch screen).InteractiveObject
 InheritedDispatched when the user lifts the point of contact over the same InteractiveObject instance on which the contact was initiated on a touch-enabled device (such as presses and releases a finger from a single point over a display object on a mobile phone or tablet with a touch screen).InteractiveObject
Styles

Styles are either common or associated with a specific theme. If the style is common, it can be used with any theme. If a style is associated with a specific theme, it can only be used if your application uses that theme.

Common Styles
 Style Description Defined By
 InheritedType: Class
Language Version: ActionScript 3.0  Product Version: Flash CS3  Runtime Versions: Flash9.0.28.0, AIR 1.0

The class that provides the cell renderer for each item in the component.
SelectableList
  
columnDividerSkin
Type: Class
Language Version: ActionScript 3.0  Product Version: Flash CS3  Runtime Versions: Flash9.0.28.0, AIR 1.0

The name of the class that provides the divider that appears between columns. The default value is DataGrid_columnDividerSkin.
DataGrid
  
columnStretchCursorSkin
Type: Class
Language Version: ActionScript 3.0  Product Version: Flash CS3  Runtime Versions: Flash9.0.28.0, AIR 1.0

The name of the class that provides the cursor that is used when the mouse is between two column headers and the resizableColumns property is set to true. The default value is DataGrid_columnStretchCursorSkin.
DataGrid
 InheritedType: Number Format: Length
Language Version: ActionScript 3.0  Product Version: Flash CS3  Runtime Versions: Flash9.0.28.0, AIR 1.0

The padding that separates the border of the list from its contents, in pixels.
SelectableList
 InheritedType: Number
Language Version: ActionScript 3.0  Product Version: Flash CS3  Runtime Versions: Flash9.0.28.0, AIR 1.0

The alpha value to set the list to when the enabled property is false.
SelectableList
 InheritedType: flash.text.TextFormat
Language Version: ActionScript 3.0  Product Version: Flash CS3  Runtime Versions: Flash9.0.28.0, AIR 1.0

The TextFormat object to use to render the component label when the button is disabled.
UIComponent
 InheritedType: Class
Language Version: ActionScript 3.0  Product Version: Flash CS3  Runtime Versions: Flash9.0.28.0, AIR 1.0

Name of the class to use as the skin for the down arrow button of the scroll bar when it is disabled.
BaseScrollPane
 InheritedType: Class
Language Version: ActionScript 3.0  Product Version: Flash CS3  Runtime Versions: Flash9.0.28.0, AIR 1.0

Name of the class to use as the skin for the down arrow button of the scroll bar when you click the arrow button.
BaseScrollPane
 InheritedType: Class
Language Version: ActionScript 3.0  Product Version: Flash CS3  Runtime Versions: Flash9.0.28.0, AIR 1.0

Name of the class to use as the skin for the down arrow button of the scroll bar when the mouse pointer is over the arrow button.
BaseScrollPane
 InheritedType: Class
Language Version: ActionScript 3.0  Product Version: Flash CS3  Runtime Versions: Flash9.0.28.0, AIR 1.0

Name of the class to use as the skin for the down arrow button of the scroll bar.
BaseScrollPane
 InheritedType: Number Format: Length
Language Version: ActionScript 3.0  Product Version: Flash CS3  Runtime Versions: Flash9.0.28.0, AIR 1.0

The padding that separates the outside boundaries of the component from the outside edges of the focus indicator, in pixels.
UIComponent
 InheritedType: Class
Language Version: ActionScript 3.0  Product Version: Flash CS3  Runtime Versions: Flash9.0.28.0, AIR 1.0

The skin to be used to display focus indicators.
UIComponent
  
headerDisabledSkin
Type: Class
Language Version: ActionScript 3.0  Product Version: Flash CS3  Runtime Versions: Flash9.0.28.0, AIR 1.0

The name of the class that provides the background for each column header when the component is disabled. The default value is HeaderRenderer_disabledSkin.
DataGrid
  
headerDisabledTextFormat
Type: flash.text.TextFormat
Language Version: ActionScript 3.0  Product Version: Flash CS3  Runtime Versions: Flash9.0.28.0, AIR 1.0

The format to be applied to the text contained in each column header when the component is disabled. The default value is null.
DataGrid
  
headerDownSkin
Type: Class
Language Version: ActionScript 3.0  Product Version: Flash CS3  Runtime Versions: Flash9.0.28.0, AIR 1.0

The name of the class that provides the background for each column header when the mouse is down. The default value is HeaderRenderer_downSkin.
DataGrid
  
headerOverSkin
Type: Class
Language Version: ActionScript 3.0  Product Version: Flash CS3  Runtime Versions: Flash9.0.28.0, AIR 1.0

The name of the class that provides the background for each column header when the mouse is over it. The default value is HeaderRenderer_overSkin.
DataGrid
  
headerRenderer
Type: Class
Language Version: ActionScript 3.0  Product Version: Flash CS3  Runtime Versions: Flash9.0.28.0, AIR 1.0

The name of the class that provides each column header. The default value is fl.controls.dataGridClasses.HeaderRenderer.
DataGrid
  
headerSortArrowAscSkin
Type: Class
Language Version: ActionScript 3.0  Product Version: Flash CS3  Runtime Versions: Flash9.0.28.0, AIR 1.0

The name of the class that provides the sort arrow when the sorted column is in ascending order. The default value is HeaderSortArrow_ascIcon.
DataGrid
  
headerSortArrowDescSkin
Type: Class
Language Version: ActionScript 3.0  Product Version: Flash CS3  Runtime Versions: Flash9.0.28.0, AIR 1.0

The name of the class that provides the sort arrow when the sorted column is in descending order. The default value is HeaderSortArrow_descIcon.
DataGrid
  
headerTextFormat
Type: flash.text.TextFormat
Language Version: ActionScript 3.0  Product Version: Flash CS3  Runtime Versions: Flash9.0.28.0, AIR 1.0

The format to be applied to the text contained in each column header. The default value is null.
DataGrid
  
headerTextPadding
Type: Number Format: Length
Language Version: ActionScript 3.0  Product Version: Flash CS3  Runtime Versions: Flash9.0.28.0, AIR 1.0

The padding that separates the column header border from the column header text, in pixels. The default value is 5.
DataGrid
  
headerUpSkin
Type: Class
Language Version: ActionScript 3.0  Product Version: Flash CS3  Runtime Versions: Flash9.0.28.0, AIR 1.0

The name of the class that provides the background for each column header. The default value is HeaderRenderer_upSkin.
DataGrid
 InheritedType: Number Format: Time
Language Version: ActionScript 3.0  Product Version: Flash CS3  Runtime Versions: Flash9.0.28.0, AIR 1.0

The number of milliseconds to wait after the buttonDown event is first dispatched before sending a second buttonDown event.
BaseScrollPane
 InheritedType: Number Format: Time
Language Version: ActionScript 3.0  Product Version: Flash CS3  Runtime Versions: Flash9.0.28.0, AIR 1.0

The interval, in milliseconds, between buttonDown events that are dispatched after the delay that is specified by the repeatDelay style.
BaseScrollPane
 InheritedType: Class
Language Version: ActionScript 3.0  Product Version: Flash CS3  Runtime Versions: Flash9.0.28.0, AIR 1.0

The class that provides the skin for the background of the component.
SelectableList
 InheritedType: flash.text.TextFormat
Language Version: ActionScript 3.0  Product Version: Flash CS3  Runtime Versions: Flash9.0.28.0, AIR 1.0

The TextFormat object to use to render the component label.
UIComponent
 InheritedType: Class
Language Version: ActionScript 3.0  Product Version: Flash CS3  Runtime Versions: Flash9.0.28.0, AIR 1.0

The skin that is used to indicate the disabled state of the thumb.
BaseScrollPane
 InheritedType: Class
Language Version: ActionScript 3.0  Product Version: Flash CS3  Runtime Versions: Flash9.0.28.0, AIR 1.0

Name of the class to use as the skin for the thumb of the scroll bar when you click the thumb.
BaseScrollPane
 InheritedType: Class
Language Version: ActionScript 3.0  Product Version: Flash CS3  Runtime Versions: Flash9.0.28.0, AIR 1.0

Name of the class to use as the icon for the thumb of the scroll bar.
BaseScrollPane
 InheritedType: Class
Language Version: ActionScript 3.0  Product Version: Flash CS3  Runtime Versions: Flash9.0.28.0, AIR 1.0

Name of the class to use as the skin for the thumb of the scroll bar when the mouse pointer is over the thumb.
BaseScrollPane
 InheritedType: Class
Language Version: ActionScript 3.0  Product Version: Flash CS3  Runtime Versions: Flash9.0.28.0, AIR 1.0

Name of the class to use as the skin used for the thumb of the scroll bar.
BaseScrollPane
 InheritedType: Class
Language Version: ActionScript 3.0  Product Version: Flash CS3  Runtime Versions: Flash9.0.28.0, AIR 1.0

The skin that is used to indicate a disabled track.
BaseScrollPane
 InheritedType: Class
Language Version: ActionScript 3.0  Product Version: Flash CS3  Runtime Versions: Flash9.0.28.0, AIR 1.0

The skin that is used to indicate the down state of a disabled skin.
BaseScrollPane
 InheritedType: Class
Language Version: ActionScript 3.0  Product Version: Flash CS3  Runtime Versions: Flash9.0.28.0, AIR 1.0

The skin that is used to indicate the mouseover state for the scroll track.
BaseScrollPane
 InheritedType: Class
Language Version: ActionScript 3.0  Product Version: Flash CS3  Runtime Versions: Flash9.0.28.0, AIR 1.0

The skin used to indicate the mouse up state for the scroll track.
BaseScrollPane
 InheritedType: Class
Language Version: ActionScript 3.0  Product Version: Flash CS3  Runtime Versions: Flash9.0.28.0, AIR 1.0

Name of the class to use as the skin for the up arrow button of the scroll bar when it is disabled.
BaseScrollPane
 InheritedType: Class
Language Version: ActionScript 3.0  Product Version: Flash CS3  Runtime Versions: Flash9.0.28.0, AIR 1.0

Name of the class to use as the skin for the up arrow button of the scroll bar when you click the arrow button.
BaseScrollPane
 InheritedType: Class
Language Version: ActionScript 3.0  Product Version: Flash CS3  Runtime Versions: Flash9.0.28.0, AIR 1.0

Name of the class to use as the skin for the up arrow button of the scroll bar when the mouse pointer is over the arrow button.
BaseScrollPane
 InheritedType: Class
Language Version: ActionScript 3.0  Product Version: Flash CS3  Runtime Versions: Flash9.0.28.0, AIR 1.0

Name of the class to use as the skin for the up arrow button of the scroll bar.
BaseScrollPane
Public Constants
 ConstantDefined By
 Inheritedversion : String = "3.0.3.1"
The version number of the components.
UIComponent
Property Detail

columns

property
columns:Array

Language Version: ActionScript 3.0
Product Version: Flash CS3
Runtime Versions: Flash Player 9.0.28.0, AIR 1.0

Gets or sets an array of DataGridColumn objects, one for each column that can be displayed. If not explicitly set, the DataGrid component examines the first item in the data provider, locates its properties, and then displays those properties in alphabetic order.

You can make changes to the columns and to their order in this DataGridColumn array. After the changes are made, however, you must explicitly assign the changed array to the columns property. If an explicit assignment is not made, the set of columns that was used before will continue to be used.

The default value is [].



Implementation
    public function get columns():Array
    public function set columns(value:Array):void

Example  ( How to use this example )
The following example adds new columns to the data grid using the columns array:

import fl.controls.DataGrid;
import fl.controls.ScrollPolicy;
import fl.data.DataProvider;

var i:uint;
var totalRows:uint = 16;
var dp:DataProvider = new DataProvider();
for (i = 0; i < totalRows; i++) {
    dp.addItem({col1:getRandomNumber(), col2:getRandomNumber(), col3:getRandomNumber(), col4:getRandomNumber()});
}

var dg:DataGrid = new DataGrid();
dg.setSize(200, 300);
dg.columns = ["col1", "col2", "col3"];
dg.dataProvider = dp;
addChild(dg);

function getRandomNumber():uint {
    return Math.round(Math.random() * 100);
}
The following example populates a new DataGrid and returns the number of columns using both the columns array and the getColumnCount() method:

import fl.controls.DataGrid;
import fl.controls.ScrollPolicy;
import fl.data.DataProvider;

var i:uint;
var totalRows:uint = 16;
var dp:DataProvider = new DataProvider();
for (i = 0; i < totalRows; i++) {
    dp.addItem({col1:getRandomNumber(), col2:getRandomNumber(), col3:getRandomNumber(), col4:getRandomNumber()});
}

var dg:DataGrid = new DataGrid();
dg.setSize(200, 300);
dg.columns = ["col1", "col2", "col3"];
dg.dataProvider = dp;
addChild(dg);

trace("columns.length:", dg.columns.length); // 3
trace("getColumnCount():", dg.getColumnCount()); // 3

function getRandomNumber():uint {
    return Math.round(Math.random() * 100);
}

editable

property 
public var editable:Boolean = false

Language Version: ActionScript 3.0
Product Version: Flash CS3
Runtime Versions: Flash Player 9.0.28.0, AIR 1.0

Indicates whether or not the user can edit items in the data provider. A value of true indicates that the user can edit items in the data provider; a value of false indicates that the user cannot.

If this value is true, the item renderers in the component are editable. The user can click on an item renderer to open an editor.

You can turn off editing for individual columns of the DataGrid component by using the DataGridColumn.editable property, or by handling the itemEditBeginning and itemEditBegin events.

The default value is false.

Related API Elements

editedItemPosition

property 
editedItemPosition:Object

Language Version: ActionScript 3.0
Product Version: Flash CS3
Runtime Versions: Flash Player 9.0.28.0, AIR 1.0

Gets or sets the column and row index of the item renderer for the data provider item that is being edited. If no item is being edited, this property is null.

This object has two fields:

  • columnIndex: The zero-based column index of the current item
  • rowIndex: The zero-based row index of the current item

For example: { columnIndex:2, rowIndex:3 }

Setting this property scrolls the item into view and dispatches the itemEditBegin event to open an item editor on the specified item renderer.

The default value is null.



Implementation
    public function get editedItemPosition():Object
    public function set editedItemPosition(value:Object):void

Related API Elements


Example  ( How to use this example )
The following example provides input fields in which the user can specify the row and column to edit within a data grid. The DataGrid, Button, Label, TextInput components must be in the library of the FLA file that is published for this example to function correctly:
import fl.data.DataProvider;
import fl.controls.*;

var dp:DataProvider = new DataProvider();
var totalEntries:uint = 42;
var i:uint;
for(i=0; i<totalEntries; i++) {
    dp.addItem( {     col1:"CellName",
                    col2:"CellName",
                    col3:"CellName" } );            
}

var dg:DataGrid = new DataGrid();
dg.columns = [ "col1", "col2", "col3" ];
dg.editable = true;
dg.dataProvider = dp;
dg.move(200,10);
dg.setSize(200,300);
addChild(dg);

var rowIntro:Label = new Label();
rowIntro.text = "Row to edit:";
rowIntro.move(10,10);

var colIntro:Label = new Label();
colIntro.text = "Column to edit:";
colIntro.move(10,30);

var rowInputField:TextInput = new TextInput();
rowInputField.move(100,10);
rowInputField.setSize(30,20);

var colInputField:TextInput = new TextInput();
colInputField.move(100,30);
colInputField.setSize(30,20);

var editButton:Button = new Button();
editButton.move(10,60);
editButton.label = "Edit";
editButton.addEventListener(MouseEvent.CLICK,editGrid);

addChild(rowIntro);
addChild(colIntro);
addChild(rowInputField);
addChild(colInputField);
addChild(editButton);

function editGrid(e:MouseEvent):void {
    dg.editedItemPosition = { rowIndex:Number(rowInputField.text), columnIndex:Number(colInputField.text) };
}

editedItemRenderer

property 
editedItemRenderer:ICellRenderer  [read-only]

Language Version: ActionScript 3.0
Product Version: Flash CS3
Runtime Versions: Flash Player 9.0.28.0, AIR 1.0

Gets a reference to the item renderer in the DataGrid component whose item is currently being edited. If no item is being edited, this property contains a value of null.

You can obtain the current value of the item that is being edited by using the editedItemRenderer.data property from an event listener for the itemEditBegin event or the itemEditEnd event.

This is a read-only property. To set a custom item editor, use the itemEditor property of the class that represents the relevant column.



Implementation
    public function get editedItemRenderer():ICellRenderer

Related API Elements


Example  ( How to use this example )
The following example provides input fields in which the user can specify the row and column to edit within a data grid. The DataGrid, Button, Label, TextInput components must be in the library of the FLA file that is published for this example to function correctly:
import fl.data.DataProvider;
import fl.controls.*;

var dp:DataProvider = new DataProvider();
var totalEntries:uint = 42;
var i:uint;
for(i=0; i<totalEntries; i++) {
    dp.addItem( {     col1:"CellName",
                    col2:"CellName",
                    col3:"CellName" } );            
}

var dg:DataGrid = new DataGrid();
dg.columns = [ "col1", "col2", "col3" ];
dg.editable = true;
dg.dataProvider = dp;
dg.move(200,10);
dg.setSize(200,300);
addChild(dg);

var rowIntro:Label = new Label();
rowIntro.text = "Row to edit:";
rowIntro.move(10,10);

var colIntro:Label = new Label();
colIntro.text = "Column to edit:";
colIntro.move(10,30);

var rowInputField:TextInput = new TextInput();
rowInputField.move(100,10);
rowInputField.setSize(30,20);

var colInputField:TextInput = new TextInput();
colInputField.move(100,30);
colInputField.setSize(30,20);

var editButton:Button = new Button();
editButton.move(10,60);
editButton.label = "Edit";
editButton.addEventListener(MouseEvent.CLICK,editGrid);

addChild(rowIntro);
addChild(colIntro);
addChild(rowInputField);
addChild(colInputField);
addChild(editButton);

function editGrid(e:MouseEvent):void {
    dg.editedItemPosition = { rowIndex:Number(rowInputField.text), columnIndex:Number(colInputField.text) };
}

headerHeight

property 
headerHeight:Number

Language Version: ActionScript 3.0
Product Version: Flash CS3
Runtime Versions: Flash Player 9.0.28.0, AIR 1.0

Gets or sets the height of the DataGrid header, in pixels.

The default value is 25.



Implementation
    public function get headerHeight():Number
    public function set headerHeight(value:Number):void

Related API Elements


Example  ( How to use this example )
The following example uses a slider to change the headerHeight property of a DataGrid component instance:

import fl.controls.DataGrid;
import fl.controls.Slider;
import fl.events.SliderEvent;

var headerHeightSlider:Slider = new Slider();
headerHeightSlider.minimum = 20;
headerHeightSlider.maximum = 40;
headerHeightSlider.snapInterval = 2;
headerHeightSlider.tickInterval = 4;
headerHeightSlider.liveDragging = true;
headerHeightSlider.move(10, 10);
headerHeightSlider.addEventListener(SliderEvent.CHANGE, changeHandler);
addChild(headerHeightSlider);

var myDataGrid:DataGrid = new DataGrid();
myDataGrid.headerHeight = headerHeightSlider.value;
myDataGrid.addColumn("name");
myDataGrid.addColumn("value");
myDataGrid.addItem({name:"Person A", value:0.85});
myDataGrid.addItem({name:"Person B", value:0.87});
myDataGrid.width = 200;
myDataGrid.rowCount = myDataGrid.length;
myDataGrid.move(10, 30);
addChild(myDataGrid);

function changeHandler(event:SliderEvent):void {
    myDataGrid.headerHeight = event.value;
    myDataGrid.rowCount = myDataGrid.length;
}

horizontalScrollPolicy

property 
horizontalScrollPolicy:String[override]

Language Version: ActionScript 3.0
Product Version: Flash CS3
Runtime Versions: Flash Player 9.0.28.0, AIR 1.0

Gets or sets a Boolean value that indicates whether the horizontal scroll bar is always on. The following list describes the valid values:

  • ScrollPolicy.ON: The scroll bar is always on.
  • ScrollPolicy.OFF: The scroll bar is always off.
  • ScrollPolicy.AUTO: The state of the scroll bar changes based on the parameters that are passed to the setScrollBarProperties() method.

Note: If the combined width of the visible columns in the DataGrid component is smaller than the available width of the DataGrid component, the columns may not expand to fill the available space of the DataGrid component, depending on the value of the horizontalScrollPolicy property. The following list describes these values and their effects:

  • ScrollPolicy.ON: The horizontal scroll bar is disabled. The columns do not expand to fill the available space of the DataGrid component.
  • ScrollPolicy.AUTO: The horizontal scroll bar is not visible. The columns do not expand to fill the available space of the DataGrid component.

The default value is ScrollPolicy.OFF.



Implementation
    override public function get horizontalScrollPolicy():String
    override public function set horizontalScrollPolicy(value:String):void

Related API Elements


Example  ( How to use this example )
The following example creates a data grid that uses a horizontal scrolling bar to provide more space for its cells:

import fl.controls.DataGrid;
import fl.controls.ScrollPolicy;
import fl.data.DataProvider;

var i:uint;
var totalRows:uint = 42;
var dp:DataProvider = new DataProvider();
for (i = 0; i < totalRows; i++) {
    dp.addItem({col1:getRandomNumber(), col2:getRandomNumber(), col3:getRandomNumber(), col4:getRandomNumber(), col5:getRandomNumber(), col6:getRandomNumber(), col7:getRandomNumber()});
}

var dg:DataGrid = new DataGrid();
dg.setSize(200,300);
dg.addColumn("col1");
dg.addColumn("col2");
dg.addColumn("col3");
dg.addColumn("col4");
dg.addColumn("col5");
dg.addColumn("col6");
dg.addColumn("col7");
dg.dataProvider = dp;
dg.horizontalScrollPolicy = ScrollPolicy.ON;
addChild(dg);

function getRandomNumber():uint {
    return Math.round(Math.random() * 100);
}

imeMode

property 
imeMode:String

Language Version: ActionScript 3.0
Product Version: Flash CS3
Runtime Versions: Flash Player 9.0.28.0, AIR 1.0

Gets or sets the mode of the input method editor (IME). The IME makes it possible for users to use a QWERTY keyboard to enter characters from the Chinese, Japanese, and Korean character sets.

Flash sets the IME to the specified mode when the component gets focus, and restores it to the original value after the component loses focus.

The flash.system.IMEConversionMode class defines constants for the valid values for this property. Set this property to null to prevent the use of the IME with the component.



Implementation
    public function get imeMode():String
    public function set imeMode(value:String):void

Related API Elements

itemEditorInstance

property 
public var itemEditorInstance:Object

Language Version: ActionScript 3.0
Product Version: Flash CS3
Runtime Versions: Flash Player 9.0.28.0, AIR 1.0

A reference to the currently active instance of the item editor, if one exists.

To access the item editor instance and the new item value when an item is being edited, use the itemEditorInstance property. The itemEditorInstance property is not valid until after the event listener for the itemEditBegin event executes. For this reason, the itemEditorInstance property is typically accessed from the event listener for the itemEditEnd event.

The DataGridColumn.itemEditor property defines the class of the item editor, and therefore, the data type of the item editor instance.

Related API Elements


Example  ( How to use this example )
The following example accesses the itemEditorInstance property of a data grid to determine the text of a cell after it has been edited:
import fl.data.DataProvider;
import fl.controls.DataGrid;
import fl.controls.dataGridClasses.DataGridCellEditor;
import fl.controls.listClasses.ListData;
import fl.events.DataGridEvent;

var dp:DataProvider = new DataProvider();
var totalEntries:uint = 42;
var i:uint;
for(i=0; i<totalEntries; i++) {
    dp.addItem( {     col1:"CellName",
                    col2:"CellName",
                    col3:"CellName" } );            
}

var dg:DataGrid = new DataGrid();
dg.addEventListener(DataGridEvent.ITEM_EDIT_END,onItemEditEnd);
dg.dataProvider = dp;
dg.editable = true;
dg.setSize(300,200);
addChild(dg);

function onItemEditEnd(e:DataGridEvent):void {
    var cellEditor:DataGridCellEditor = dg.itemEditorInstance as DataGridCellEditor;
    var listData:ListData = cellEditor.listData;
    trace("After Edit: " + cellEditor.text);
}

labelFunction

property 
labelFunction:Function

Language Version: ActionScript 3.0
Product Version: Flash CS3
Runtime Versions: Flash Player 9.0.28.0, AIR 1.0

Gets or sets a function that determines which fields of each item to use for the label text.

The default value is null.



Implementation
    public function get labelFunction():Function
    public function set labelFunction(value:Function):void

Example  ( How to use this example )
The following example uses a label function for each column in the data grid:

import fl.controls.DataGrid;
import fl.controls.ScrollPolicy;
import fl.controls.dataGridClasses.DataGridColumn;
import fl.data.DataProvider;

var i:uint;
var totalRows:uint = 16;
var dp:DataProvider = new DataProvider();
for (i = 0; i < totalRows; i++) {
    dp.addItem({col1:getRandomNumber(), col2:getRandomNumber(), col3:getRandomNumber(), col4:getRandomNumber()});
}

var c1:DataGridColumn = new DataGridColumn("col1");
c1.sortOptions = Array.NUMERIC;
var c2:DataGridColumn = new DataGridColumn("col2");
c2.sortOptions = Array.NUMERIC;
var c3:DataGridColumn = new DataGridColumn("col3");
c3.sortOptions = Array.NUMERIC;

var dg:DataGrid = new DataGrid();
dg.addColumn(c1);
dg.addColumn(c2);
dg.addColumn(c3);
dg.dataProvider = dp;
dg.labelFunction = currencyFormatter;
dg.move(10, 10);
dg.setSize(200, 300);
addChild(dg);

function getRandomNumber():Number {
    return Math.random() * 100;
}

function currencyFormatter(data:Object, column:DataGridColumn):String {
    return "$" + data[column.dataField].toFixed(2);
}

minColumnWidth

property 
minColumnWidth:Number

Language Version: ActionScript 3.0
Product Version: Flash CS3
Runtime Versions: Flash Player 9.0.28.0, AIR 1.0

Gets or sets the minimum width of a DataGrid column, in pixels. If this value is set to NaN, the minimum column width can be individually set for each column of the DataGrid component.

The default value is NaN.



Implementation
    public function get minColumnWidth():Number
    public function set minColumnWidth(value:Number):void

Example  ( How to use this example )
The following example enables horizontal scrolling of a data grid and sets the minimum column width to 185, large enough to fit the width of the sample string:
import fl.controls.DataGrid;
import fl.controls.ScrollPolicy;
import fl.data.DataProvider;

var i:uint;
var totalRows:uint = 42;
var dp:DataProvider = new DataProvider();
for (i = 0; i < totalRows; i++) {
    dp.addItem({col1:getString(), col2:getString(), col3:getString(), col4:getString(), col5:getString(), col6:getString(), col7:getString()});
}

var dg:DataGrid = new DataGrid();
dg.setSize(450,300);
dg.addColumn("col1");
dg.addColumn("col2");
dg.addColumn("col3");
dg.addColumn("col4");
dg.addColumn("col5");
dg.addColumn("col6");
dg.addColumn("col7");
dg.dataProvider = dp;
dg.horizontalScrollPolicy = ScrollPolicy.ON;
dg.minColumnWidth = 185;
addChild(dg);

function getString():String {
    return "This string requires a wide column";
}

resizableColumns

property 
public var resizableColumns:Boolean = true

Language Version: ActionScript 3.0
Product Version: Flash CS3
Runtime Versions: Flash Player 9.0.28.0, AIR 1.0

Indicates whether the user can change the size of the columns. A value of true indicates that the user can change the column size; a value of false indicates that column size is fixed.

If this value is true, the user can stretch or shrink the columns of the DataGrid component by dragging the grid lines between the header cells. Additionally, if this value is true, the user can change the size of the columns unless the resizeable properties of individual columns are set to false.

The default value is true.

Related API Elements


Example  ( How to use this example )
The following example creates a DataGrid component instance and sets its resizableColumns and sortableColumns to false:

import fl.controls.DataGrid;
import fl.controls.dataGridClasses.DataGridColumn;

var nameCol:DataGridColumn = new DataGridColumn("name");
nameCol.headerText = "NAME:";
nameCol.width = 120;

var valueCol:DataGridColumn = new DataGridColumn("value");
valueCol.headerText = "VALUE:";
valueCol.width = 80;

var myDataGrid:DataGrid = new DataGrid();
myDataGrid.addColumn(nameCol);
myDataGrid.addColumn(valueCol);
myDataGrid.addItem({name:"Name A", value:"Value A"});
myDataGrid.addItem({name:"Name B", value:"Value B"});
myDataGrid.addItem({name:"Name C", value:"Value C"});
myDataGrid.resizableColumns = false;
myDataGrid.sortableColumns = false;
myDataGrid.width = 200;
myDataGrid.rowCount = myDataGrid.length;
myDataGrid.move(10, 10);
addChild(myDataGrid);

rowCount

property 
rowCount:uint[override]

Language Version: ActionScript 3.0
Product Version: Flash CS3
Runtime Versions: Flash Player 9.0.28.0, AIR 1.0

Gets or sets the number of rows that are at least partially visible in the list.



Implementation
    override public function get rowCount():uint
    override public function set rowCount(value:uint):void

Related API Elements


Example  ( How to use this example )
The following example creates a DataGrid component instance and resizes the data grid using the rowCount property:

import fl.controls.DataGrid;
import fl.data.DataProvider;

var dp:DataProvider = new DataProvider();
dp.addItem({col1:"item 1.A", col2:"item 1.B", col3:"item 1.C"});
dp.addItem({col1:"item 2.A", col2:"item 2.B", col3:"item 2.C"});
dp.addItem({col1:"item 3.A", col2:"item 3.B", col3:"item 3.C"});
dp.addItem({col1:"item 4.A", col2:"item 4.B", col3:"item 4.C"});

var myDataGrid:DataGrid = new DataGrid();
myDataGrid.addColumn("col1");
myDataGrid.addColumn("col2");
myDataGrid.addColumn("col3");
myDataGrid.dataProvider = dp;
myDataGrid.move(10, 10);
myDataGrid.setSize(300, 200);
addChild(myDataGrid);

var fixedHeight:uint = Math.min(myDataGrid.rowCount, myDataGrid.length);
myDataGrid.rowCount = fixedHeight;

trace(myDataGrid.width, myDataGrid.height); // 300 105

rowHeight

property 
rowHeight:Number

Language Version: ActionScript 3.0
Product Version: Flash CS3
Runtime Versions: Flash Player 9.0.28.0, AIR 1.0

Gets or sets the height of each row in the DataGrid component, in pixels.

The default value is 20.



Implementation
    public function get rowHeight():Number
    public function set rowHeight(value:Number):void

Related API Elements


Example  ( How to use this example )
The following example adjusts the height of the rows in a data grid and reduces the text size of all the components on the Stage:
import fl.controls.DataGrid;
import fl.controls.dataGridClasses.DataGridColumn;
import fl.data.DataProvider;
import fl.managers.StyleManager;

var dp:DataProvider = new DataProvider();
var totalEntries:uint = 42;
var i:uint;
for(i = 0; i < totalEntries; i++) {
    dp.addItem( { col1:Math.random(), col2:Math.random(), col3:Math.random() } );           
}

var smallText:TextFormat = new TextFormat();
smallText.size = 9;
smallText.font = "Verdana";

var dg:DataGrid = new DataGrid();
dg.columns = ["col1", "col2", "col3"];
dg.rowHeight = 14;
dg.move(10, 10);
dg.setSize(400, 300);
dg.dataProvider = dp;
dg.setStyle("textFormat", smallText);
addChild(dg);

StyleManager.setStyle("textFormat", smallText);

showHeaders

property 
showHeaders:Boolean

Language Version: ActionScript 3.0
Product Version: Flash CS3
Runtime Versions: Flash Player 9.0.28.0, AIR 1.0

Gets or sets a Boolean value that indicates whether the DataGrid component shows column headers. A value of true indicates that the DataGrid component shows column headers; a value of false indicates that it does not.

The default value is true.



Implementation
    public function get showHeaders():Boolean
    public function set showHeaders(value:Boolean):void

Example  ( How to use this example )
The following example creates two data grids, one with column headers and one without:
import fl.controls.DataGrid;
import fl.controls.ScrollPolicy;
import fl.data.DataProvider;

var i:uint;
var totalRows:uint = 42;
var dp:DataProvider = new DataProvider();
for (i = 0; i < totalRows; i++) {
    dp.addItem({col1:Math.random(), col2:Math.random()});
}

var dg1:DataGrid = new DataGrid();
dg1.move(10,10);
dg1.setSize(200,300);
dg1.dataProvider = dp;
addChild(dg1);

var dg2:DataGrid = new DataGrid();
dg2.move(250,10);
dg2.setSize(200,300);
dg2.dataProvider = dp;
dg2.showHeaders = false;
addChild(dg2);

sortableColumns

property 
public var sortableColumns:Boolean = true

Language Version: ActionScript 3.0
Product Version: Flash CS3
Runtime Versions: Flash Player 9.0.28.0, AIR 1.0

Indicates whether the user can sort the items in the data provider by clicking on a column header cell. If this value is true, the user can sort the data provider items by clicking on a column header cell; if this value is false, the user cannot.

If this value is true, to prevent an individual column from responding to a user mouse click on a header cell, set the sortable property of that column to false.

The sort field of a column is either the dataField or sortCompareFunction property of the DataGridColumn component. If the user clicks a column more than one time, the sort operation alternates between ascending and descending order.

If both this property and the sortable property of a column are set to true, the DataGrid component dispatches a headerRelease event after the user releases the mouse button of the column header cell. If a call is not made to the preventDefault() method from a handler method of the headerRelease event, the DataGrid component performs a sort based on the values of the dataField or sortCompareFunction properties.

The default value is true.

Related API Elements


Example  ( How to use this example )
The following example creates a DataGrid component instance and sets its sortableColumns property to false to prevent the list from being user sortable:

import fl.controls.DataGrid;
import fl.controls.dataGridClasses.DataGridColumn;
import fl.data.DataProvider;
import fl.events.DataGridEvent;

var data:XML = <dataProvider>
        <data col1="Person A" col2="11.383" />
        <data col1="Person B" col2="3.399" />
        <data col1="Person C" col2="25.624" />
    </dataProvider>

var dp:DataProvider = new DataProvider(data);

var c1:DataGridColumn = new DataGridColumn("col1");
var c2:DataGridColumn = new DataGridColumn("col2");

var myDataGrid:DataGrid = new DataGrid();
myDataGrid.addColumn(c1);
myDataGrid.addColumn(c2);
myDataGrid.dataProvider = dp;
myDataGrid.move(10, 10);
myDataGrid.setSize(160, 120);
myDataGrid.sortableColumns = false;
addChild(myDataGrid);

sortDescending

property 
sortDescending:Boolean  [read-only]

Language Version: ActionScript 3.0
Product Version: Flash CS3
Runtime Versions: Flash Player 9.0.28.0, AIR 1.0

Gets the order in which a column is sorted when the user clicks its header. A value of true indicates that the column is sorted in descending order; a value of false indicates that the column is sorted in ascending order.

The sortDescending property does not affect how the sort method completes the sort operation. By default, the sort operation involves a case-sensitive string sort. To change this behavior, modify the sortOptions and sortCompareFunction properties of the DataGridColumn class.

Note: If you query this property from an event listener for the headerRelease event, the property value identifies the sort order for the previous sort operation. This is because the next sort has not yet occurred.

The default value is false.



Implementation
    public function get sortDescending():Boolean

Related API Elements


Example  ( How to use this example )
The following example creates a DataGrid component instance, listens for the headerRelease and traces the sortDescending, sortIndex, and dataField properties:

import fl.controls.DataGrid;
import fl.controls.dataGridClasses.DataGridColumn;
import fl.data.DataProvider;
import fl.events.DataGridEvent;

var dataXML:XML = <dataProvider>
        <data col1="Person A" col2="11.383" />
        <data col1="Person B" col2="3.399" />
        <data col1="Person C" col2="25.624" />
    </dataProvider>

var dp:DataProvider = new DataProvider(dataXML);

var c1:DataGridColumn = new DataGridColumn("col1");
var c2:DataGridColumn = new DataGridColumn("col2");
c2.sortOptions = Array.NUMERIC;

var myDataGrid:DataGrid = new DataGrid();
myDataGrid.addColumn(c1);
myDataGrid.addColumn(c2);
myDataGrid.dataProvider = dp;
myDataGrid.width = 160;
myDataGrid.rowCount = myDataGrid.length;
myDataGrid.move(10, 10);
myDataGrid.addEventListener(DataGridEvent.HEADER_RELEASE, headerReleaseHandler);
addChild(myDataGrid);

function headerReleaseHandler(event:DataGridEvent):void {
    var myDG:DataGrid = event.currentTarget as DataGrid;
    var whichColumn:DataGridColumn = myDG.getColumnAt(event.columnIndex);
    trace("sortDescending:", myDG.sortDescending);
    trace("sortIndex:", myDG.sortIndex);
    trace("dataField:", whichColumn.dataField);
    trace("");
}

sortIndex

property 
sortIndex:int  [read-only]

Language Version: ActionScript 3.0
Product Version: Flash CS3
Runtime Versions: Flash Player 9.0.28.0, AIR 1.0

Gets the index of the column to be sorted.

The default value is -1.



Implementation
    public function get sortIndex():int

Related API Elements

Constructor Detail

DataGrid

()Constructor
public function DataGrid()

Language Version: ActionScript 3.0
Product Version: Flash CS3
Runtime Versions: Flash Player 9.0.28.0, AIR 1.0

Creates a new DataGrid component instance.

Method Detail

addColumn

()method
public function addColumn(column:*):DataGridColumn

Language Version: ActionScript 3.0
Product Version: Flash CS3
Runtime Versions: Flash Player 9.0.28.0, AIR 1.0

Adds a column to the end of the columns array.

Parameters

column:* — A String or a DataGridColumn object.

Returns
DataGridColumn — The DataGridColumn object that was added.

Related API Elements


Example  ( How to use this example )

The following example creates a DataGrid component instance and adds two columns by passing a string to the addColumn() method:

import fl.controls.DataGrid;

var myDataGrid:DataGrid = new DataGrid();
myDataGrid.addColumn("name");
myDataGrid.addColumn("value");
myDataGrid.addItem({name:"Name 1", value:"Value 1"});
myDataGrid.addItem({name:"Name 2", value:"Value 2"});
myDataGrid.addItem({name:"Name 3", value:"Value 3"});
myDataGrid.width = 200;
myDataGrid.rowCount = myDataGrid.length;
myDataGrid.move(10, 10);
addChild(myDataGrid);

The following example creates a DataGrid component instance and adds two columns by passing a DataGridColumn object to the addColumn() method:

import fl.controls.DataGrid;
import fl.controls.dataGridClasses.DataGridColumn;

var nameCol:DataGridColumn = new DataGridColumn("name");
var valueCol:DataGridColumn = new DataGridColumn("value");

var myDataGrid:DataGrid = new DataGrid();
myDataGrid.addColumn(nameCol);
myDataGrid.addColumn(valueCol);
myDataGrid.addItem({name:"Name 1", value:"Value 1"});
myDataGrid.addItem({name:"Name 2", value:"Value 2"});
myDataGrid.addItem({name:"Name 3", value:"Value 3"});
myDataGrid.width = 200;
myDataGrid.rowCount = myDataGrid.length;
myDataGrid.move(10, 10);
addChild(myDataGrid);

The following example specifies an order and size for its columns by manually adding them before setting its data provider:
import fl.controls.DataGrid;
import fl.controls.dataGridClasses.DataGridColumn;
import fl.data.DataProvider;

var dp:DataProvider = new DataProvider();
dp.addItem( { stateName:"California", stateAbbreviation:"CA" } );
dp.addItem( { stateName:"New York", stateAbbreviation:"NY" } );

var dg:DataGrid = new DataGrid();
var abbreviationColumn:DataGridColumn = dg.addColumn(new DataGridColumn("stateAbbreviation"));                                            
var nameColumn:DataGridColumn = dg.addColumn("stateName");
abbreviationColumn.width = 100;
nameColumn.width = 200;

dg.move(10,10);
dg.width = 300;
dg.rowCount = 2;
dg.dataProvider = dp;
addChild(dg);

addColumnAt

()method 
public function addColumnAt(column:*, index:uint):DataGridColumn

Language Version: ActionScript 3.0
Product Version: Flash CS3
Runtime Versions: Flash Player 9.0.28.0, AIR 1.0

Inserts a column at the specified index in the columns array.

Parameters

column:* — The string or DataGridColumn object that represents the column to be inserted.
 
index:uint — The array index that identifies the location at which the column is to be inserted.

Returns
DataGridColumn — The DataGridColumn object that was inserted into the array of columns.

Related API Elements


Example  ( How to use this example )

The following example specifies an order and size for its columns by manually adding them before setting its data provider:
import fl.controls.DataGrid;
import fl.controls.dataGridClasses.DataGridColumn;
import fl.data.DataProvider;

var dp:DataProvider = new DataProvider();
dp.addItem( { stateName:"California", stateAbbreviation:"CA" } );
dp.addItem( { stateName:"New York", stateAbbreviation:"NY" } );

var dg:DataGrid = new DataGrid();
var abbreviationColumn:DataGridColumn = dg.addColumn(new DataGridColumn("stateAbbreviation"));                                            
var nameColumn:DataGridColumn = dg.addColumn("stateName");
abbreviationColumn.width = 100;
nameColumn.width = 200;

dg.move(10,10);
dg.width = 300;
dg.rowCount = 2;
dg.dataProvider = dp;
addChild(dg);

createItemEditor

()method 
public function createItemEditor(colIndex:uint, rowIndex:uint):void

Language Version: ActionScript 3.0
Product Version: Flash CS3
Runtime Versions: Flash Player 9.0.28.0, AIR 1.0

Uses the editor specified by the itemEditor property to create an item editor for the item renderer at the column and row index identified by the editedItemPosition property.

This method sets the editor instance as the itemEditorInstance property.

You can call this method from the event listener for the itemEditBegin event. To create an editor from other code, set the editedItemPosition property to generate the itemEditBegin event.

Parameters

colIndex:uint — The column index of the item to be edited in the data provider.
 
rowIndex:uint — The row index of the item to be edited in the data provider.

destroyItemEditor

()method 
public function destroyItemEditor():void

Language Version: ActionScript 3.0
Product Version: Flash CS3
Runtime Versions: Flash Player 9.0.28.0, AIR 1.0

Closes an item editor that is currently open on an item renderer. This method is typically called from the event listener for the itemEditEnd event, after a call is made to the preventDefault() method to prevent the default event listener from executing.

editField

()method 
public function editField(index:uint, dataField:String, data:Object):void

Language Version: ActionScript 3.0
Product Version: Flash CS3
Runtime Versions: Flash Player 9.0.28.0, AIR 1.0

Edits a given field or property in the DataGrid component.

Parameters

index:uint — The index of the data provider item to be edited.
 
dataField:String — The name of the field or property in the data provider item to be edited.
 
data:Object — The new data value.

Throws
RangeError — The specified index is less than 0 or greater than or equal to the length of the data provider.

getCellRendererAt

()method 
public function getCellRendererAt(row:uint, column:uint):ICellRenderer

Language Version: ActionScript 3.0
Product Version: Flash CS3
Runtime Versions: Flash Player 9.0.28.0, AIR 1.0

Get the instance of a cell renderer at the specified position in the DataGrid.

Note: This method returns null for positions that are not visible (i.e. scrolled out of the view).

Parameters

row:uint — A row index.
 
column:uint — A column index.

Returns
ICellRenderer — The ICellRenderer object at the specified position, or null if no cell renderer exists at that position.

getColumnAt

()method 
public function getColumnAt(index:uint):DataGridColumn

Language Version: ActionScript 3.0
Product Version: Flash CS3
Runtime Versions: Flash Player 9.0.28.0, AIR 1.0

Retrieves the column that is located at the specified index of the columns array.

Parameters

index:uint — The index of the column to be retrieved, or null if a column is not found.

Returns
DataGridColumn — The DataGridColumn object that was found at the specified index.

Related API Elements

getColumnCount

()method 
public function getColumnCount():uint

Language Version: ActionScript 3.0
Product Version: Flash CS3
Runtime Versions: Flash Player 9.0.28.0, AIR 1.0

Retrieves the number of columns in the DataGrid component.

Returns
uint — The number of columns contained in the DataGrid component.

Related API Elements


Example  ( How to use this example )

The following example populates a new DataGrid and returns the number of columns using both the columns array and the getColumnCount() method:

import fl.controls.DataGrid;
import fl.controls.ScrollPolicy;
import fl.data.DataProvider;

var i:uint;
var totalRows:uint = 16;
var dp:DataProvider = new DataProvider();
for (i = 0; i < totalRows; i++) {
    dp.addItem({col1:getRandomNumber(), col2:getRandomNumber(), col3:getRandomNumber(), col4:getRandomNumber()});
}

var dg:DataGrid = new DataGrid();
dg.setSize(200, 300);
dg.columns = ["col1", "col2", "col3"];
dg.dataProvider = dp;
addChild(dg);

trace("columns.length:", dg.columns.length); // 3
trace("getColumnCount():", dg.getColumnCount()); // 3

function getRandomNumber():uint {
    return Math.round(Math.random() * 100);
}

The following example creates a DataGrid and traces out the width of each data grid column whenever the columnStretch event is dispatched:

import fl.controls.DataGrid;
import fl.controls.dataGridClasses.DataGridColumn;
import fl.events.DataGridEvent;

var nameCol:DataGridColumn = new DataGridColumn("name");
var valueCol:DataGridColumn = new DataGridColumn("value");

var myDataGrid:DataGrid = new DataGrid();
myDataGrid.addColumn(nameCol);
myDataGrid.addColumn(valueCol);
myDataGrid.addItem({name:"Name 1", value:"Value 1"});
myDataGrid.addItem({name:"Name 2", value:"Value 2"});
myDataGrid.addItem({name:"Name 3", value:"Value 3"});
myDataGrid.width = 200;
myDataGrid.rowCount = myDataGrid.length;
myDataGrid.move(10, 10);
myDataGrid.addEventListener(DataGridEvent.COLUMN_STRETCH, columnStretchHandler);
addChild(myDataGrid);

function columnStretchHandler(event:DataGridEvent):void {
    var col:DataGridColumn;
    for each (col in myDataGrid.columns) {
        trace(col.dataField + ":", col.width + "px")
    }
    trace("");
}

getColumnIndex

()method 
public function getColumnIndex(name:String):int

Language Version: ActionScript 3.0
Product Version: Flash CS3
Runtime Versions: Flash Player 9.0.28.0, AIR 1.0

Retrieves the index of the column of the specified name, or -1 if no match is found.

Parameters

name:String — The data field of the column to be located.

Returns
int — The index of the location at which the column of the specified name is found.

Related API Elements

getStyleDefinition

()method 
public static function getStyleDefinition():Object

Language Version: ActionScript 3.0
Product Version: Flash CS3
Runtime Versions: Flash Player 9.0.28.0, AIR 1.0

Retrieves the default style map for the current component. The style map contains the type that is appropriate for the component, depending on the style that the component uses. For example, the disabledTextFormat style contains a value of null or a TextFormat object. You can use these styles and call setStyle() on the current component. The following code overrides the default disabledTextFormat style on the specified component:

componentInstance.setStyle("disabledTextFormat", new TextFormat());

Returns
Object — Default styles object.

Related API Elements


Example  ( How to use this example )

The following example creates a style browser for several component classes:
import fl.controls.*;
import fl.containers.*;
import fl.controls.listClasses.*;
import fl.controls.dataGridClasses.*;
import fl.controls.progressBarClasses.*;
import fl.core.UIComponent;
import fl.data.DataProvider;

var dp:DataProvider = new DataProvider();
dp.addItem( { label: "BaseScrollPane",    data:BaseScrollPane } );
dp.addItem( { label: "Button",             data:Button } );
dp.addItem( { label: "CellRenderer",    data:CellRenderer } );
dp.addItem( { label: "CheckBox",         data:CheckBox } );
dp.addItem( { label: "ColorPicker",     data:ColorPicker } );
dp.addItem( { label: "ComboBox",         data:ComboBox } );
dp.addItem( { label: "DataGrid",         data:DataGrid } );
dp.addItem( { label: "HeaderRenderer",    data:HeaderRenderer } );
dp.addItem( { label: "ImageCell",        data:ImageCell } );
dp.addItem( { label: "IndeterminateBar",data:IndeterminateBar } );
dp.addItem( { label: "Label",             data:Label } );
dp.addItem( { label: "List",             data:List } );
dp.addItem( { label: "NumericStepper",     data:NumericStepper } );
dp.addItem( { label: "ProgressBar",     data:ProgressBar } );
dp.addItem( { label: "RadioButton",     data:RadioButton } );
dp.addItem( { label: "ScrollPane",         data:ScrollPane } );
dp.addItem( { label: "Slider",             data:Slider } );
dp.addItem( { label: "TextArea",         data:TextArea } );
dp.addItem( { label: "TextInput",         data:TextInput } );
dp.addItem( { label: "TileList",         data:TileList } );
dp.addItem( { label: "UILoader",         data:UILoader } );
dp.addItem( { label: "UIComponent",     data:UIComponent } );

var cb:ComboBox = new ComboBox();
cb.move(10,10);
cb.setSize(300,25);
cb.prompt = "Select a component to view its styles";
cb.rowCount = 12;
cb.dataProvider = dp;
cb.addEventListener(Event.CHANGE, showStyleDefinition);
addChild(cb);

var dg:DataGrid = new DataGrid();
dg.setSize(425,300);
dg.move(10,50);
dg.columns = [ new DataGridColumn("StyleName"), new DataGridColumn("DefaultValue") ];
addChild(dg);

function showStyleDefinition(e:Event):void {
    var componentClass:Class = e.target.selectedItem.data as Class;
    var styles:Object = componentClass["getStyleDefinition"].call(this);
    trace(styles.toString());
    var styleData:DataProvider = new DataProvider();
    for(var i:* in styles) {
        trace(i + " : " + styles[i]);
        styleData.addItem( { StyleName:i, DefaultValue:styles[i] } );
    }
    styleData.sortOn("StyleName");
    dg.dataProvider = styleData;
}

itemToCellRenderer

()method 
override public function itemToCellRenderer(item:Object):ICellRenderer

Language Version: ActionScript 3.0
Product Version: Flash CS3
Runtime Versions: Flash Player 9.0.28.0, AIR 1.0

The DataGrid component has multiple cells for any given item, so the itemToCellRenderer method always returns null.

Parameters

item:Object — The item in the data provider.

Returns
ICellRenderernull.

removeAllColumns

()method 
public function removeAllColumns():void

Language Version: ActionScript 3.0
Product Version: Flash CS3
Runtime Versions: Flash Player 9.0.28.0, AIR 1.0

Removes all columns from the DataGrid component.

Related API Elements

removeColumnAt

()method 
public function removeColumnAt(index:uint):DataGridColumn

Language Version: ActionScript 3.0
Product Version: Flash CS3
Runtime Versions: Flash Player 9.0.28.0, AIR 1.0

Removes the column that is located at the specified index of the columns array.

Parameters

index:uint — The index of the column to be removed.

Returns
DataGridColumn — The DataGridColumn object that was removed. This method returns null if a column is not found at the specified index.

Related API Elements

scrollToIndex

()method 
override public function scrollToIndex(newCaretIndex:int):void

Language Version: ActionScript 3.0
Product Version: Flash CS3
Runtime Versions: Flash Player 9.0.28.0, AIR 1.0

Scrolls the list to the item at the specified index. If the index is out of range, the scroll position does not change.

Parameters

newCaretIndex:int — The index location to scroll to.

spaceColumnsEqually

()method 
public function spaceColumnsEqually():void

Language Version: ActionScript 3.0
Product Version: Flash CS3
Runtime Versions: Flash Player 9.0.28.0, AIR 1.0

Resets the widths of the visible columns to the same size.

Event Detail

columnStretch

Event
Event Object Type: fl.events.DataGridEvent
property DataGridEvent.type = fl.events.DataGridEvent.COLUMN_STRETCH

Language Version: ActionScript 3.0
Product Version: Flash CS3
Runtime Versions: Flash Player 9.0.28.0, AIR 1.0

Dispatched after a user expands a column horizontally.

The DataGridEvent.COLUMN_STRETCH constant defines the value of the type property of a columnStretch event object.

This event has the following properties:

PropertyValue
bubblesfalse
cancelablefalse; there is no default behavior to cancel.
columnIndexThe zero-based index of the header column in the columns array of the DataGrid object.
currentTargetThe object that is actively processing the event object with an event listener.
dataFieldThe name of the field or property in the data associated with the column of the item.
itemRendererThe header renderer for the column that was stretched.
reasonnull
rowIndexThe zero-based index of the item in the data provider.
targetThe object that dispatched the event. The target is not always the object listening for the event. Use the currentTarget property to access the object that is listening for the event.

Example  ( How to use this example )

The following example creates a DataGrid component and listens for its columnStretch event:

import fl.controls.DataGrid;
import fl.controls.dataGridClasses.DataGridColumn;
import fl.data.DataProvider;
import fl.events.DataGridEvent;

var dp:DataProvider = new DataProvider();
dp.addItem({col1:"item 1.A", col2:"item 1.B", col3:"item 1.C"});
dp.addItem({col1:"item 2.A", col2:"item 2.B", col3:"item 2.C"});
dp.addItem({col1:"item 3.A", col2:"item 3.B", col3:"item 3.C"});
dp.addItem({col1:"item 4.A", col2:"item 4.B", col3:"item 4.C"});

var myDataGrid:DataGrid = new DataGrid();
myDataGrid.addColumn("col1");
myDataGrid.addColumn("col2");
myDataGrid.addColumn("col3");
myDataGrid.dataProvider = dp;
myDataGrid.setSize(300, 200);
myDataGrid.move(10, 10);
myDataGrid.addEventListener(DataGridEvent.COLUMN_STRETCH, columnStretchHandler);
addChild(myDataGrid);

function columnStretchHandler(event:DataGridEvent):void {
    var dg:DataGrid = event.target as DataGrid;
    var column:DataGridColumn;
    var columnArray:Array = dg.columns;
    var dgColWidth:String;
    trace("resized column:", event.dataField);
    trace("columnIndex:", event.columnIndex);
    for each (column in columnArray) {
        dgColWidth = Number(column.width / dg.width * 100).toFixed(1);
        trace(column.dataField + ".width:", column.width + " pixels (" + dgColWidth + "%)");
    }
    trace("----------");
}

headerRelease

Event  
Event Object Type: fl.events.DataGridEvent
property DataGridEvent.type = fl.events.DataGridEvent.HEADER_RELEASE

Language Version: ActionScript 3.0
Product Version: Flash CS3
Runtime Versions: Flash Player 9.0.28.0, AIR 1.0

Dispatched after the user clicks a header cell.

The DataGridEvent.HEADER_RELEASE constant defines the value of the type property of a headerRelease event object.

This event has the following properties:

PropertyValue
bubblesfalse
cancelablefalse; there is no default behavior to cancel.
columnIndexThe zero-based index of the header column in the columns array of the DataGrid object.
currentTargetThe object that is actively processing the event object with an event listener.
dataFieldThe name of the field or property in the data associated with the column of the item.
itemRendererThe header renderer that was clicked.
reasonnull
rowIndex-1
targetThe object that dispatched the event. The target is not always the object listening for the event. Use the currentTarget property to access the object that is listening for the event.

Example  ( How to use this example )

The following example creates a DataGrid component instance and listens for its headerRelease event:

import fl.controls.DataGrid;
import fl.controls.dataGridClasses.DataGridColumn;
import fl.data.DataProvider;
import fl.events.DataGridEvent;

var dp:DataProvider = new DataProvider();
dp.addItem({col1:"item 1.A", col2:"item 1.B", col3:"item 1.C"});
dp.addItem({col1:"item 2.A", col2:"item 2.B", col3:"item 2.C"});
dp.addItem({col1:"item 3.A", col2:"item 3.B", col3:"item 3.C"});
dp.addItem({col1:"item 4.A", col2:"item 4.B", col3:"item 4.C"});

var myDataGrid:DataGrid = new DataGrid();
myDataGrid.addColumn("col1");
myDataGrid.addColumn("col2");
myDataGrid.addColumn("col3");
myDataGrid.dataProvider = dp;
myDataGrid.setSize(300, 200);
myDataGrid.move(10, 10);
myDataGrid.addEventListener(DataGridEvent.HEADER_RELEASE, headerReleaseHandler);
addChild(myDataGrid);

function headerReleaseHandler(event:DataGridEvent):void {
    var dg:DataGrid = event.target as DataGrid;
    trace("dataField:", event.dataField, "(columnIndex:" + event.columnIndex + ")");
    trace("sortIndex:", dg.sortIndex);
    trace("sortDescending:", dg.sortDescending);
    trace("----------");
}

itemEditBegin

Event  
Event Object Type: fl.events.DataGridEvent
property DataGridEvent.type = fl.events.DataGridEvent.ITEM_EDIT_BEGIN

Language Version: ActionScript 3.0
Product Version: Flash CS3
Runtime Versions: Flash Player 9.0.28.0, AIR 1.0

Dispatched after the editedItemPosition property is set and the item can be edited.

The DataGridEvent.ITEM_EDIT_BEGIN constant defines the value of the type property of an itemEditBegin event object.

This event has the following properties:

PropertyValue
bubblesfalse
cancelablefalse; there is no default behavior to cancel.
columnIndexThe zero-based index of the header column in the columns array of the DataGrid object.
currentTargetThe object that is actively processing the event object with an event listener.
dataFieldnull
itemRendererThe item renderer for the item to be edited.
reasonnull
rowIndexThe zero-based index of the item in the data provider.
targetThe object that dispatched the event. The target is not always the object listening for the event. Use the currentTarget property to access the object that is listening for the event.

Related API Elements

itemEditBeginning

Event  
Event Object Type: fl.events.DataGridEvent
property DataGridEvent.type = fl.events.DataGridEvent.ITEM_EDIT_BEGINNING

Language Version: ActionScript 3.0
Product Version: Flash CS3
Runtime Versions: Flash Player 9.0.28.0, AIR 1.0

Dispatched after a user prepares to edit an item, for example, by releasing the mouse button over the item.

The DataGridEvent.ITEM__EDIT_BEGINNING constant defines the value of the type property of an itemEditBeginning event object.

This event has the following properties:

PropertyValue
bubblesfalse
cancelablefalse; there is no default behavior to cancel.
columnIndexThe zero-based index of the header column in the columns array of the DataGrid object.
currentTargetThe object that is actively processing the event object with an event listener.
dataFieldThe name of the field or property in the data associated with the column of the item.
itemRendererThe item renderer for the item to be edited.
reasonnull
rowIndexThe zero-based index of the item in the data provider.
targetThe object that dispatched the event. The target is not always the object listening for the event. Use the currentTarget property to access the object that is listening for the event.

Related API Elements

itemEditEnd

Event  
Event Object Type: fl.events.DataGridEvent
property DataGridEvent.type = fl.events.DataGridEvent.ITEM_EDIT_END

Language Version: ActionScript 3.0
Product Version: Flash CS3
Runtime Versions: Flash Player 9.0.28.0, AIR 1.0

Dispatched when an item editing session ends for any reason.

The DataGridEvent.ITEM_EDIT_END constant defines the value of the type property of an itemEditEnd event object.

This event has the following properties:

PropertyValue
bubblesfalse
cancelablefalse; there is no default behavior to cancel.
columnIndexThe zero-based index of the header column in the columns array of the DataGrid object.
currentTargetThe object that is actively processing the event object with an event listener.
dataFieldThe name of the field or property in the data associated with the column of the item.
itemRendererThe item renderer for the item to be edited.
reasonA constant defining the reason for the event. The value must be a member of the DataGridEventReason class.
rowIndexThe zero-based index of the item in the data provider.
targetThe object that dispatched the event. The target is not always the object listening for the event. Use the currentTarget property to access the object that is listening for the event.

Related API Elements

itemFocusIn

Event  
Event Object Type: fl.events.DataGridEvent
property DataGridEvent.type = fl.events.DataGridEvent.ITEM_FOCUS_IN

Language Version: ActionScript 3.0
Product Version: Flash CS3
Runtime Versions: Flash Player 9.0.28.0, AIR 1.0

Dispatched after an item receives focus.

The DataGridEvent.ITEM_FOCUS_IN constant defines the value of the type property of a itemFocusIn event object.

This event has the following properties:

PropertyValue
bubblesfalse
cancelablefalse; there is no default behavior to cancel.
columnIndexThe zero-based index of the header column in the columns array of the DataGrid object.
currentTargetThe object that is actively processing the event object with an event listener.
dataFieldnull
itemRendererThe item renderer for the item to be edited.
reasonnull
rowIndexThe zero-based index of the item in the data provider.
targetThe object that dispatched the event. The target is not always the object listening for the event. Use the currentTarget property to access the object that is listening for the event.

Related API Elements

itemFocusOut

Event  
Event Object Type: fl.events.DataGridEvent
property DataGridEvent.type = fl.events.DataGridEvent.ITEM_FOCUS_OUT

Language Version: ActionScript 3.0
Product Version: Flash CS3
Runtime Versions: Flash Player 9.0.28.0, AIR 1.0

Dispatched after an item loses focus.

The DataGridEvent.ITEM_FOCUS_OUT constant defines the value of the type property of an itemFocusOut event object.

This event has the following properties:

PropertyValue
bubblesfalse
cancelablefalse; there is no default behavior to cancel.
columnIndexThe zero-based index of the header column in the columns array of the DataGrid object.
currentTargetThe object that is actively processing the event object with an event listener.
dataFieldnull
itemRendererThe item renderer for the item to be edited.
reasonnull
rowIndexThe zero-based index of the item in the data provider.
targetThe object that dispatched the event. The target is not always the object listening for the event. Use the currentTarget property to access the object that is listening for the event.

Related API Elements

DataGridExample.as

This example demonstrates how to dynamically create a DataGrid and listen to its events.
  1. Add the DataGrid component to the library.
  2. Save this code as DataGridExample.as in the same directory as your FLA.
  3. Set the DocumentClass in the FLA to DataGridExample.
package 
{
    import flash.display.Sprite;
    import flash.events.Event;
    import flash.text.TextField;
    import fl.controls.DataGrid;
    
    public class DataGridExample extends Sprite
    {
        var sampleItem1:Object = { Name:"John Alpha",     Number:"555-123-0101", Email:"jalpha@fictitious.com" };
        var sampleItem2:Object = { Name:"Mary Bravo",     Number:"555-372-3322", Email:"mbravo@fictitious.com" };
        var sampleItem3:Object = { Name:"Trevor Gamma", Number:"555-485-1212", Email:"tgamma@fictitious.com" };
        var sampleItem4:Object = { Name:"Susan Delta",     Number:"555-987-3434", Email:"sdelta@fictitious.com" };        
        
        var dg:DataGrid;
        var tf1:TextField;
        var tf2:TextField;
        var tf3:TextField;
        
        public function DataGridExample() {
            createDataGrid();
            createTextFields();
        }
        private function createDataGrid():void {
            dg = new DataGrid();
            dg.move(10,10);
            dg.setSize(500,125);
            dg.columns = ["Name","Number","Email"];
            dg.addItem(sampleItem1);
            dg.addItem(sampleItem2);
            dg.addItem(sampleItem3);
            dg.addItem(sampleItem4);
            
            dg.addEventListener("change",gridItemSelected);
            dg.minColumnWidth = dg.width / 3;
            addChild(dg);
        }
        private function createTextFields():void {
            tf1 = new TextField();
            tf2 = new TextField();
            tf3 = new TextField();
            tf1.x = 
            tf2.x = 
            tf3.x = 10;
            tf1.autoSize =
            tf2.autoSize =
            tf3.autoSize = "left";
            tf1.y = 150;
            tf2.y = 175;
            tf3.y = 200;
            
            addChild(tf1);
            addChild(tf2);
            addChild(tf3);            
        }
        private function gridItemSelected(e:Event):void {
            tf1.text = "Name: " + e.target.selectedItem.Name;
            tf2.text = "Number: " + e.target.selectedItem.Number;
            tf3.text = "Email: " + e.target.selectedItem.Email;            
        }
    }
}