| Methods | Properties | Effects | Events | Styles | Examples | Frames | No Frames |
The DataGrid control is a List that can show more than one column of data.
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:DataGridClick here to view the Examples
cellEditor="No default."
cellRenderer="No default."
columns="No default."
columnName="No default."
dataProvider="No default."
editable="false|true"
focusedCell="No default."
headerColors="[0xE6EEEE, 0xFFFFFF]"
headerHeight="20"
headerStyle="No default."
hGridLineColor="#666666"
hGridLines="false|true"
resizableColumns="true|false"
rollOverColor="#0xE3FFD6"
selectable="true|false"
selectionColor="#0xCDFFC1"
showHeaders="true|false"
sortableColumns="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."
columnStretch="Event handler; no default."
headerRelease="Event handler; no default."
>
Following is a DataGrid sample Code Specifying the Column Order:
<mx:DataGrid>
<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
gridclasses.DataGridColumn
gridclasses.DataGridRow
mx.effects.Tween
mx.managers.CursorManager
| Methods | |
| addColumn(
newCol)
:
mx.controls.gridclasses.DataGridColumnAppends a column to the end of the DataGrid. |
| addColumnAt(
index:
Number, newCol)
:
mx.controls.gridclasses.DataGridColumnAdds a column at the specified index. |
| draw(
)
Creates the headers, draws the rows and cells, then sizes and draws the column headers. |
| editField(
index:
Number, colName:
String, data)
:
VoidUpdates the value of a cell in a column with new data. |
| getColumnAt(
index:
Number)
:
mx.controls.gridclasses.DataGridColumnReturns a column at a specified location. |
| getColumnIndex(
name:
String)
:
NumberGet the index of a specified column based on the column name. |
| getRowMetrics(
)
:
ObjectSame as the getViewMetrics() method, but factors in the headerHeight. |
| layoutChildren(
)
:
Void Sizes and positions the column headers, columns, and cells based on the size of the DataGrid. |
| measure(
)
Measures the DataGrid based on its contents, summing the total of the visible column widths. |
| placeSortArrow(
)
:
Void Draw the sortArrow graphic on the column that is the current sortIndex. |
| removeAllColumns(
)
:
VoidRemoves all columns. |
| removeColumnAt(
index:
Number)
:
mx.controls.gridclasses.DataGridColumnRemoves a column at the specified location. |
| Methods inherited from class mx.core.ScrollView |
childLoaded
createChildren
createChildWithStyles
getViewMetrics
init
layoutChildren
setScrollProperties
|
| Methods inherited from class mx.core.UIComponent |
drawFocus
getFocus
getFocusManager
setEnabled
setFocus
|
| Properties | |
| cellEditor:
MovieClip A reference to the cell editor, if it exists. |
| columnCount:
Number
[Read-Only]
Number of columns that can be displayed. |
| columnNames:
ArrayAn array of strings used to generate the column headers. |
| columns:
ArrayAn array of DataGridColumns, one for each visible column |
| editable:
BooleanIf true, the cells in the control are editable (provided their columns are marked as editable) and the user can click on a cell and an editor will popup. |
| focusedCell:
ObjectCreates the cellEditor on the specified cell. |
| header_mc:
MovieClip The column headers are all children of this MovieClip. |
| headerHeight:
NumberHeight of the header bar of the grid, in pixels. |
| lines_mc:
MovieClip The layer on which to draw grid lines between columns. |
| minColWidth:
Number Resizable columns are not shrunk below this number of pixels. |
| resizableColumns:
BooleanIf true, the user can stretch the columns of the DataGrid control by dragging the grid lines between the headers. |
| selectable:
BooleanIf true, the user can select DataGrid items. |
| showHeaders:
BooleanIf true, the DataGrid control shows column headers. |
| sortableColumns:
BooleanIf true, the user can sort the columns of the DataGrid control by clicking on the headers. |
| sortArrow:
MovieClip Specifies the small arrow graphic used to show sortable columns and direction. |
| stretchBar:
MovieClip Specifies a graphic that shows the proposed column width as the user stretches it. |
| stretcher:
MovieClip Specifies the cursor used to show that you can stretch a column. |
static | version:
StringVersion string for this class. |
| Properties inherited from class mx.controls.List |
version
|
| Properties inherited from class mx.core.ScrollView |
className
hPosition
hScrollPolicy
liveScrolling
maxHPosition
maxVPosition
scrollTipFunction
showScrollTips
version
vPosition
vScrollPolicy
|
| Properties inherited from class mx.core.View |
baselinePosition
className
numChildren
version
|
| Properties inherited from class mx.core.UIComponent |
enabled
errorString
tabEnabled
tabIndex
version
|
| Effects |
| Effects inherited from class mx.core.UIComponent |
focusInEffect
focusOutEffect
|
| Effects inherited from class mx.core.UIObject |
creationCompleteEffect
hideEffect
mouseDownEffect
mouseOutEffect
mouseOverEffect
mouseUpEffect
moveEffect
resizeEffect
showEffect
|
| Events | |
cellEdit | Broadcast when a cell's value has been changed via a cell editor. Only broadcast if the cell/column is editable. The event object contains the properties: - itemIndex Index of the selected item.- columnIndex Index of the selected column.- oldValue Previous value of the cell.- target Reference to the component that triggered the event. - type Name of the event. |
cellFocusIn | Broadcast when a cell gets focus which can occur if the user clicks on a cell or navigates to the cell via keyboard. The event object contains the properties: - itemIndex Index of the selected item.- columnIndex Index of the selected column.- target Reference to the component that triggered the event. - type Name of the event. |
cellFocusOut | Broadcast when a cell loses focus which can occur if the user clicks on another cell, or outside the grid, or navigates to another cell or outside the grid via keyboard. The event object contains the properties: - itemIndex Index of the selected item.- columnIndex Index of the selected column.- target Reference to the component that triggered the event. - type Name of the event. |
cellPress | Broadcast when the user clicks on a cell to indicate that the cell is about to be edited. The event object contains the properties: - itemIndex Index of the selected item.- columnIndex Index of the selected column.- view Currently selected Object.- target Reference to the component that triggered the event. - type Name of the event. |
columnStretch | Broadcast when a user stretches a column horizontally indicating that the amount of data displayed in that column has changed. If hScrollPolicy is none, other columns will shrink or stretch to compensate for the columns resizing and they will also broadcast this event. The event object contains the properties: - columnIndex Index of the selected column.- target Reference to the component that triggered the event. - type Name of the event. |
headerRelease | Broadcast when a column header is pressed and released, indicating that a sort operation is about to occur. Only broadcast if the column is sortable. The event object contains the properties: - view Currently selected Object.- columnIndex Index of the selected column.- target Reference to the component that triggered the event. - type Name of the event. |
| Events inherited from class: mx.controls.listclasses.ScrollSelectList |
change itemRollOut itemRollOver |
| Events inherited from class: mx.core.ScrollView |
scroll |
| Events inherited from class: mx.core.View |
childCreated childDestroyed childIndexChanged |
| Events inherited from class: mx.core.UIComponent |
focusIn focusOut invalid keyDown keyUp valid valueCommitted |
| Styles | |
backgroundDisabledColor |
Type:
Number
Format:
Color
CSS Inheritance:
yesBackground color of the grid when disabled. The default value is 0xEFEEEF. |
hGridLineColor |
Type:
Number
Format:
Color
CSS Inheritance:
yesColor of the horizontal grid lines. The default value is 0x666666. |
hGridLines |
Type:
Boolean
CSS Inheritance:
noIf true, shows horizontal grid lines. If false, hides horizontal grid lines. The default value is false. |
headerColor |
Type:
Number
Format:
Color
CSS Inheritance:
yesColor of the column headers. Deprecated - use headerColors instead. |
headerColors |
Type:
Array
CSS Inheritance:
yesArray of two colors used to draw the header. The first color is the top color. The second color is the bottom color. The default values are (0xE6EEEE, 0xFFFFFF). |
headerStyle |
Type:
String
CSS Inheritance:
noCSS style declaration for the column header that you apply to a grid or column. |
rollOverColor |
Type:
Number
Format:
Color
CSS Inheritance:
yesColor of the background when the user rolls over the link. The default value is 0xE3FFD6. |
selectionColor |
Type:
Number
Format:
Color
CSS Inheritance:
yesColor of the background when the user selectes the link. The default value is 0xCDFFC1. |
vGridLineColor |
Type:
Number
Format:
Color
CSS Inheritance:
yesColor of the vertical grid lines. The default value is 0x666666. |
vGridLines |
Type:
Boolean
CSS Inheritance:
noIf true, shows vertical grid lines. If false, hides vertical grid lines. The default is false. |
| Styles inherited from class mx.core.UIObject |
color
fontFamily
fontSize
fontStyle
fontWeight
horizontalGap
leading
marginLeft
marginRight
textAlign
textDecoration
textIndent
verticalGap
|
| Method Detail |
addColumn(
newCol)
:
mx.controls.gridclasses.DataGridColumn
Parameters
newCol - The string name of the new column, or a DataGridColumn.
Returns
The new column.
addColumnAt(
index:
Number, newCol)
:
mx.controls.gridclasses.DataGridColumn
Parameters
index:
Number - The index for the new column.
newCol - The string name of the new column, or a DataGridColumn.
Returns
The new column.
draw(
)
editField(
index:
Number, colName:
String, data)
:
Void
Parameters
index:
Number - Index of the item to edit.
colName:
String - Name of the field to edit.
data - New data to put in the edited field.
getColumnAt(
index:
Number)
:
mx.controls.gridclasses.DataGridColumn
Parameters
index:
Number - Index of the column to retrieve.
Returns
Column at the specified index.
getColumnIndex(
name:
String)
:
Number
Parameters
name:
String - Name of the column whose index you want.
Returns
The column index.
getRowMetrics(
)
:
Object
Returns
Object containing left, top, right and bottom properties.
layoutChildren(
)
:
Void
measure(
)
placeSortArrow(
)
:
Void
removeAllColumns(
)
:
Void
removeColumnAt(
index:
Number)
:
mx.controls.gridclasses.DataGridColumn
Parameters
index:
Number - Index of the column to remove.
Returns
The removed column.
| Property Detail |
cellEditor:
MovieClip
columnCount:
Number
[Read-Only]
columnNames:
Array
columns:
Array
editable:
Boolean
focusedCell:
Object
header_mc:
MovieClip
headerHeight:
Number
lines_mc:
MovieClip
minColWidth:
Number
resizableColumns:
Boolean
selectable:
Boolean
showHeaders:
Boolean
sortableColumns:
Boolean
sortArrow:
MovieClip
stretchBar:
MovieClip
stretcher:
MovieClip
static
version:
String
| Examples |
| SimpleDataGrid.mxml |
|
| DataGridExample.mxml |
|
RSS feed | Send me an e-mail when comments are added to this page | Comment Report
Current page: http://livedocs.adobe.com/flex/15/asdocs_en/mx/controls/DataGrid.html
Comments
No screen name said on Jan 15, 2005 at 5:48 AM : smgilson said on Jan 18, 2005 at 10:54 AM : No screen name said on Jan 27, 2005 at 5:47 AM : mpeterson said on Jan 27, 2005 at 10:51 AM : No screen name said on Mar 9, 2005 at 8:14 AM : smgilson said on Mar 15, 2005 at 8:54 AM : 01merced said on Mar 17, 2005 at 10:58 AM :