The DataGrid control is a list that can show more than one column of data. It is a formatted table of data that lets you set editable table cells. It is also the foundation of many data-driven applications.
The DataGrid control provides the following features:
MXML Syntax
The <mx:DataGrid> tag inherits all the properties of its parent classes, and the following properties:
<mx:DataGrid
alternatingRowColors="No default."
backgroundColor="No default."
backgroundDisabledColor="0xEFEEEF"
cellRenderer="No default."
columns="No default."
columnName="No default."
dataProvider="No default."
editable="false|true"
focusedCell="No default."
headerColor="No default."
headerHeight="20"
headerStyle="No default."
hGridLineColor="#666666"
hGridLines="false|true"
hPosition="0"
hScrollPolicy="off|on"
labelStyle="No default."
resizableColumns="true|false"
rollOverColor="#0xE3FFD6"
selectable="true"
selectionColor="#0xCDFFC1"
selectionEasing="No default."
showHeaders="true|false"
sortableColumns="true|false"
useRollOver="true|false"
vGridLineColor="#666666"
vGridLines="false|true"
cellEdit="Event handler; no default."
cellFocusIn="Event handler; no default."
cellFocusOut="Event handler; no default."
cellPress="Event handler; no default."
change="Event handler; no default."
columnStretch="Event handler; no default."
headerRelease="Event handler; no default."
>
<mx:dataProvider>
<mx:Array>
<mx:Object Artist="Pavement" Price="11.99"
Album="Slanted and Enchanted" />
<mx:Object Artist="Pavement"
Album="Brighten the Corners" Price="11.99" />
</mx:Array>
</mx:dataProvider>
<mx:columns>
<mx:Array>
<mx:DataGridColumn columnName="Album" />
<mx:DataGridColumn columnName="Price" />
</mx:Array>
</mx:columns>
</mx:DataGrid>
See Also
mx.controls.gridclasses.DataGridColumn;
mx.controls.gridclasses.DataGridRow;
mx.effects.Tween;
mx.managers.CursorManager;
| Methods | |
| addColumn(newCol) : DataGridColumn
Appends a column to the end of the DataGrid. |
| addColumnAt(index:Number, newCol) : DataGridColumn
Adds a column at the specified location. |
| disposeEditor() : Void
Returns cell to normal state after editing. |
| draw() : Void
Dispatches all scheduled drawing work in the right sequence to properly render the grid. |
| editCell() : Void
Edits the contents of a cell. |
| editField(index:Number, colName:String, data) : Void
Field to edit. |
| getColumnAt(index:Number) : DataGridColumn
Column at a specified location. |
| getColumnIndex(name:String) : Number
Location of a specified column. |
| getRowMetrics() : Object
Determines the layout of the rows inside the list. |
| initHeaders() : Void
Lays out the column headings. |
| removeAllColumns() : Void
Removes all columns. |
| removeColumnAt(index:Number) : DataGridColumn
Removes a column at the specified location. |
| setRowCount(rC:Number) : Void
Determines the layout of a specific number of rows. |
| spaceColumnsEqually() : Void
Makes all columns display with the same width. |
| startSizing() : Void
Indicates where the right side of a resized column appears. |
| stopSizing() : Void
Determines how much to resize the column. |
| tabHandler() : Void
Determines how to navigate with the Tab key. |
| Methods inherited from class mx.controls.listclasses.ScrollSelectList |
calculateWidths
setPropertiesAt
|
| Methods inherited from class mx.core.ScrollView |
setScrollProperties
getViewMetrics
createChild
|
| Methods inherited from class mx.core.View |
init
draw
createChild
getChildAt
getChildIndex
setChildIndex
destroyAllChildren
destroyChild
destroyChildAt
getViewMetrics
|
| Methods inherited from class mx.core.UIComponent |
getFocus
setFocus
getFocusManager
|
| Properties | |
static | version:String
ComponentVersion is for internal use only. |
| selectable:Boolean
If true, the user can select DataGrid items. |
| resizableColumns:Boolean
If true, the user can stretch the columns of the DataGrid control. |
| sortableColumns:Boolean
If true, the user can sort the columns of the DataGrid control by clicking on the headers. |
| editable:Boolean
If true, the text area of the control is editable. |
| columns:Array
[Read-Write]
Set of field names within each item that to display as columns. |
| columnNames:Array
[Read-Write]
Field names to display as column headings. |
| showHeaders:Boolean
[Read-Write]
If true, the DataGrid control shows column headers. |
| headerHeight:Number
[Read-Write]
Height of the header bar of the grid, in pixels. |
| Properties inherited from class mx.controls.List |
version
dataProvider
|
| Properties inherited from class mx.core.ScrollView |
version
className
hScrollPolicy
vScrollPolicy
hPosition
vPosition
maxVPosition
maxHPosition
|
| Properties inherited from class mx.core.View |
version
className
numChildren
|
| Properties inherited from class mx.core.UIComponent |
version
enabled
tabIndex
|
| Effects |
| Effects inherited from class mx.core.UIComponent |
showEffect
hideEffect
focusInEffect
focusOutEffect
|
| Effects inherited from class mx.core.UIObject |
creationCompleteEffect
moveEffect
resizeEffect
mouseDownEffect
mouseOverEffect
mouseOutEffect
mouseUpEffect
|
| Events | |
cellPress | Handler for cellPress events, which are broadcast when the user presses a particular cell. The event object contains the properties: - itemIndex Index of the selected item. - columnIndex Index of the selected column. - view Currently selected Object. Target contains a reference to the component that triggered the event. Type contains the name of the event. |
cellEdit | Handler for cellEdit events, which are broadcast when a cell value changes. Target contains a reference to the component that triggered the event. The event object contains the properties: - itemIndex Index of the selected item. - columnIndex Index of the selected column. - oldValue Previous value of the cell. Type contains the name of the event. |
cellFocusIn | Handler for cellFocusIn events, which are broadcast when a particular cell gets focus. The event object contains the properties: - itemIndex Index of the selected item. - columnIndex Index of the selected column. Target contains a reference to the component that triggered the event. Type contains the name of the event. |
cellFocusOut | Handler for cellFocusOut events, which are broadcast when a particular cell loses focus. The event object contains the properties: - itemIndex Index of the selected item. - columnIndex Index of the selected column. Target contains a reference to the component that triggered the event. Type contains the name of the event. |
columnStretch | Handler for columnStretch events, which are broadcast when a user stretches a column horizontally. The event object contains the properties: - columnIndex Index of the selected column. Target contains a reference to the component that triggered the event. Type contains the name of the event. |
headerRelease | Handler for headerRelease events, which are broadcast when a column header is released. The event object contains the properties: - view Currently selected Object. - columnIndex Index of the selected column. Target contains a reference to the component that triggered the event. Type contains the name of the event. |
| Events inherited from class: mx.controls.listclasses.ScrollSelectList |
change
itemRollOver
itemRollOut
|
| Events inherited from class: mx.core.ScrollView |
scroll
|
| Events inherited from class: mx.core.View |
childCreated
childIndexChanged
childDestroyed
|
| Events inherited from class: mx.core.UIComponent |
focusIn
focusOut
keyDown
keyUp
show
hide
valid
invalid
valueCommitted
|
| Styles | |
backgroundColor |
Type: Number
Format: Color
CSS Inheritance: yes
Background color. |
backgroundDisabledColor |
Type: Number
Format: Color
CSS Inheritance: yes
Background color of check boxes and radio buttons when disabled. The default value is 0xEFEEEF. |
vGridLines |
Type: Boolean
CSS Inheritance: no
If true, shows vertical grid lines. If false, hides vertical grid lines. The default is false. |
hGridLines |
Type: Boolean
CSS Inheritance: no
If true, shows horizontal grid lines. If false, hides horizontal grid lines. The default value is false. |
vGridLineColor |
Type: Number
Format: Color
CSS Inheritance: yes
Color of the vertical grid lines. The default value is #666666. |
hGridLineColor |
Type: Number
Format: Color
CSS Inheritance: yes
Color of the horizontal grid lines. The default value is #666666. |
headerColor |
Type: Number
Format: Color
CSS Inheritance: yes
Color of the column headers |
rollOverColor |
Type: Number
Format: Color
CSS Inheritance: yes
Color of the background when the user rolls over the link. The default value is #0xE3FFD6. |
selectionColor |
Type: Number
Format: Color
CSS Inheritance: yes
Color of the background when the user selectes the link. The default value is #0xCDFFC1. |
headerStyle |
Type: String
CSS Inheritance: yes
CSS style declaration for the column header that you apply to a grid or column. |
| Styles inherited from class mx.controls.List |
alternatingRowColors
rollOverColor
selectionColor
selectionEasing
textDisabledColor
textRollOverColor
textSelectedColor
|
| Styles inherited from class mx.core.UIObject |
color
fontFamily
fontSize
fontStyle
fontWeight
textAlign
textDecoration
textIndent
marginLeft
marginRight
horizontalGap
verticalGap
|
| Method Detail |
addColumn(newCol) : DataGridColumn
Parameters
newCol - The string name of the new column, or a DataGridColumn.
Returns
The new column.
addColumnAt(index:Number, newCol) : DataGridColumn
Parameters
index - The index for the new column.
newCol - The string name of the new column, or a DataGridColumn.
Returns
The new column.
disposeEditor() : Void
draw() :
Void
editCell() :
Void
editField(index:Number, colName:String, data) : Void
Parameters
index - Index of the item to edit.
colName - Name of the field to edit.
data - New data to put in the edited field.
getColumnAt(index:Number) : DataGridColumn
Parameters
index - Index of the column to retrieve.
Returns
Column at the specified index.
getColumnIndex(name:String) : Number
Parameters
name - Name of the column whose index you want.
Returns
The column index.
getRowMetrics() : Object
initHeaders() : Void
removeAllColumns() : Void
removeColumnAt(index:Number) : DataGridColumn
Parameters
index - Index of the column to remove.
Returns
The removed column.
setRowCount(rC:Number) : Void
Parameters
rC - row count
spaceColumnsEqually() : Void
startSizing() : Void
stopSizing() : Void
tabHandler() : Void
| Property Detail |
columnNames:Array
[Read-Write]
columns:Array
[Read-Write]
editable:Boolean
headerHeight:Number
[Read-Write]
resizableColumns:Boolean
selectable:Boolean
showHeaders:Boolean
[Read-Write]
sortableColumns:Boolean
static version:String