Main Page | Packages | Class Tree | Index | Help

xp.controls

class DataGrid

MovieClip
  |
  +--xp.system.UIControl
        |
        +--xp.controls.ScrollSelectView
              |
              +--xp.controls.ScrollSelectList
                    |
                    +--xp.controls.DataGrid


class DataGrid
extends ScrollSelectList

Allows users to display and manipulate multiple columns of data.


The DataGrid receives focus when you click it or tab to it, and you can then use the following keys to control it:
KeyDescription
ControlToggle key that allows multiple noncontiguous selections and deselections.
Down ArrowSelection moves down one item.
HomeSelection moves to the top of the list.
Page Down Selection moves down one page.
Page Up Selection moves up one page.
ShiftAllows for contiguous selection.
Up ArrowSelection moves up one item


You can then use the following keys to control it whilst editing:
KeyDescription
Shift+Tab/TabMoves focus to the previous item. When the Tab key is pressed in the last column, focus cycles from the last column in the grid to the first column on the next line. When Shift+Tab is pressed, cycling is reversed. All the text in the focused cell is selected.
Enter/Shift+EnterWhen a cell is editable, the change is committed, and the insertion point is moved to the cell on the same column, next row (up or down, depending on the shift toggle).
EscCloses the editor without saving the current changes
Control+EnterCloses the editor and saves the current changes.


Event summary for the DataGrid class
The following table lists events of the DataGrid class.




EventTypeDescription
xp.events.SelectedIndexChangedEventselectedIndexChangedBroadcast whenever user interaction causes the selection to change.
xp.events.ValueChangedEventvalueChangedBroadcast whenever user interaction causes the selection value to change.
xp.events.ItemRollOverEventitemRollOverBroadcast when the pointer rolls over list items.
xp.events.ItemRollOutEventitemRollOutBroadcast when the pointer rolls over and then off of list items.


Author:
ProWin Computers Ltd. - Rob Edgar

Version:
3.0.0.000

See also:


Field Summary

public
__showHeaders: Boolean


public
autoSync: Boolean
do we auto sync the underlying source when there is a selection

public static
classInfo: Object
A static class information object

public
columnAutoWidth: Boolean
A Boolean value that indicates whether the columns widths are adjusted proportionatley to the DataGrid width.

public
indicatorWidth: Number
Width of indicator column

public
rowStyle: Object
The list row styles

public
styleClass: String
The name of the style class this instance will use.

public
vGridLines: Boolean
controls whether vertical gridlines are displayed*

Fields inherited from class xp.controls.ScrollSelectList

classInfo

Fields inherited from class xp.controls.ScrollSelectView

__alternateColor, __backgroundColor, __hGridLineColor, __highlightColor, __selectColor, __selectedValueFormatter, __selectedValuePath, __vGridLineColor, autoSync, body, canEdit, canInsert, classInfo, editable, editorType, editRow, footer, header, hGridLines, hLargeScroll, hscrollbar, hScrollPolicy, hSmallScroll, isSelectionRequired, scrollMode, statusbar, tabStop, textHighlightColor, textSelectColor, titlebar, topIndex, useRollOver, vGridLines, vLargeScroll, vscrollbar, vScrollPolicy, vSmallScroll

Fields inherited from class xp.system.UIControl

__layout, allowDrop, autoLayout, bindingDefaultValue, bindingFormatter, bindingPath, bindingSource, bindingType, bindingValidator, border, causesValidation, classInfo, clickOnENTER, clickOnSPACE, container, context, data, disableAcceptButton, disableCancelButton, enableBGMouseEvents, enableDblClickEvent, enableKeyDownEvents, enableKeyEvents, enableKeyUpEvents, enableMouseWheelEvents, formatterOptions, horizontalAlignment, index, isBinding, itemId, logEnabled, parent, parentContainer, parentForm, percentageHeight, percentageWidth, styleClass, tabIndex, tabStop, tooltip, tree, verticalAlignment

Property Summary

public
columnCount: Number (read-only)
The number of columns that are displayed.

public
columnNames: Array (read, write)
An array of field names within each item that are displayed as columns.

public
columns (read, write)
Sets or gets the DataGrids primary or master columns

public
dataProvider: Object (read, write)
Gets or set the list items

public
footerHeight: Number (read, write)
The height of the footer RowGroup.

public
headerHeight: Number (read, write)
The height of the header RowGroup

public
headerRowHeight: Number (read, write)
the height of standard header rows-only used by addDefaultHeaders

public
resizableColumns: Boolean (read, write)
A Boolean value that indicates whether the columns are resizable (true) or not (false).

public
rowCount: Number (read-only)
Number of rows actually visible in the itemsControl

public
showHeaders: Boolean (read, write)
A Boolean value that indicates whether the data grid displays the column headers (true) or not (false).

public
sortableColumns: Boolean (read, write)
A Boolean value that indicates whether the columns are sortable (true) or not (false).

public
statusbarHeight: Number (read, write)
The height of the statusbar.

public
statusbarMessage: String (read, write)
Gets/Sets the display message in the statusbar

public
titlebarHeight: Number (read, write)
The height of the titlebar

public
titlebarMessage: String (read, write)
Gets/Sets the display message in the titlebar

public
viewportPixelHeight: 0 (read-only)
The height of the viewable window--override to allow for header footer

public
viewportTop: 0 (read-only)
The location of the top of the viewport

Properties inherited from class xp.controls.ScrollSelectList

rowCount

Properties inherited from class xp.controls.ScrollSelectView

alternateColor, backgroundColor, contentHeight, contentPixelHeight, contentWidth, hGridLineColor, highlightColor, hPosition, rowAutosize, rowHeight, rowWidth, sbHHeight, sbVWidth, selectColor, selectedIndex, selectedIndices, selectedItem, selectedItems, selectedValue, selectedValueFormatter, selectedValuePath, selectionMode, variableRowHeight, vGridLineColor, viewportHeight, viewportLeft, viewportPixelHeight, viewportTop, viewportWidth, virtualMode, vPosition

Properties inherited from class xp.system.UIControl

alpha, autosize, background, backgroundVisible, bindings, borderBrush, borderRadius, borderShadow, borderStyle, borderThickness, bottom, dataSource, enableMouseEvents, focusManager, height, id, isEnabled, isFocused, isMouseOver, isPressed, isSelected, isValid, layout, left, margin, maxHeight, maxWidth, measuredHeight, measuredMinHeight, measuredMinWidth, measuredWidth, minHeight, minWidth, padding, readOnly, resources, right, styleName, top, triggers, visible, width, x, y

Constructor

public
DataGrid ( )
Constructor - This should not be called directly.


Method Summary

public
addColumn ( colName: Object, colTitle: String, colWidth: String ): Column
Adds a columns to this DataGrid

public
addColumnAt ( index: Number, colName: Object, colTitle: String, colWidth: String ): Column
Adds a columns to this DataGrid

public
addColumns ( cols: Array ): Void
Adds a set of columns to this DataGrid columns set.

public static
calculateWidths ( columns: Array, width: Number ): Array
Converts preferred widths into actual pixels

public
generateItemUI ( ): Object
Generates an item UI for this items control

public
getClass ( ): Function
Returns a reference to the components static class

public
getColumn ( name: String ): Column
Gets a reference to the Column object with the specified name.

public
getColumnAt ( index: Number ): Column
Gets a reference to the Column object at the specified index.

public
getColumnIndex ( columnName: String ): Column
Returns the index of the column specified by the columnName parameter.

public
hideEditor ( save: Boolean ): Boolean
Hides the cell editor, called on a cellPress

public static
newInstance ( owner, instanceId, depth, initObj )
Creates a new Instance of this class

public
onSetFocus ( oldFocus: Object ): Void
SetFocus handler.Called when you get focus. If focus is actualy set to some internal TextField that TextField must call onSetFocus when it gets focus.

public
removeAllColumns ( ): Void
Removes all Columns from the target DataGrid instance.

public
removeColumnAt ( index: Number ): Column
Removes the Column instance at the given index.

public
resetColumns ( ): Void
Clears all data rows, then reinitialises the columns and reloads the data

public
resizeColumn ( index: Number, inc: Number ): Void
Resizes a column

public
scrollInView ( itemIndex: Number, columnIndex: Number )
Scrolls the ItemsControl so the specified row and cell are in view

public
selectRowForEditing ( itemIndex: Number ): Void
Callback handler called when the editor has finished editing the current row

public
setScrollContentHPos ( pos ): Void
Sets the horizontal scroll position

public
showEditor ( itemIndex: Number, columnIndex: Number ): Boolean
Shows the cell editor row

public
sortRows ( columnIndex: Number ): Void
Sort the rows of the DataGrid

public
updateVirtualRows ( start: Number, end: Number ): Void
Update the data for the visible rows in the list

Methods inherited from class xp.controls.ScrollSelectList

getClass

Methods inherited from class xp.controls.ScrollSelectView

clearSelected, drawComponent, getClass, getItemAt, getItemIndex, getItemValue, getValueIndex, isSelected, setScrollContentVPos, setSelectedIndices, setSelectedItems

Methods inherited from class xp.system.UIControl

addBinding, addBindings, addEventListener, addPropertyTrigger, applyStyle, beginDeferUpdate, canUpdate, centerContent, checkState, containsFocus, destroy, destroyObject, drawFocus, endDeferUpdate, findFocusFromObject, findFocusInChildren, getBinding, getBounds, getCenter, getClass, getFocus, getFocusManager, getFocusRect, getLocation, getPropertyValue, getSize, getStateName, getTrigger, globalToLocalPoint, invalidate, invalidateLayout, invalidateSize, invalidateSizeAndLayout, invalidChild, isChild, isMouseDirectlyOver, isParent, localToGlobalPoint, localToLocalPoint, measure, mouseWheel, move, onChildFocus, onKillFocus, onSetFocus, processEnterKey, processEscapeKey, processTabKey, redraw, refresh, removeEventListener, routeEvent, setBounds, setFocus, setLocation, setPropertyValue, setSize, setValueChanged, update, validate



Field Documentation

__showHeaders

public var __showHeaders: Boolean

autoSync

public var autoSync: Boolean
do we auto sync the underlying source when there is a selection

classInfo

public static var classInfo: Object
A static class information object

Every class has an associated classInfo object that holds the version and other static information. The classInfo can be accessed either directly by referencing the static class or by calling getClass() on any class instance.

columnAutoWidth

public var columnAutoWidth: Boolean
A Boolean value that indicates whether the columns widths are adjusted proportionatley to the DataGrid width.

indicatorWidth

public var indicatorWidth: Number
Width of indicator column

rowStyle

public var rowStyle: Object
The list row styles

styleClass

public var styleClass: String
The name of the style class this instance will use.

vGridLines

public var vGridLines: Boolean
controls whether vertical gridlines are displayed*


Property Documentation

columnCount

public columnCount: Number (read-only)
The number of columns that are displayed.

Value:
The number of columns in the columns collecton

columnNames

public columnNames: Array (read, write)
An array of field names within each item that are displayed as columns.

columns

public columns (read, write)
Sets or gets the DataGrids primary or master columns

dataProvider

public dataProvider: Object (read, write)
Gets or set the list items

An array of list items. When this property is set, internally the array is wrapped in a ListDataSource and passed to the itemsSource property

footerHeight

public footerHeight: Number (read, write)
The height of the footer RowGroup.

headerHeight

public headerHeight: Number (read, write)
The height of the header RowGroup

headerRowHeight

public headerRowHeight: Number (read, write)
the height of standard header rows-only used by addDefaultHeaders

resizableColumns

public resizableColumns: Boolean (read, write)
A Boolean value that indicates whether the columns are resizable (true) or not (false).

rowCount

public rowCount: Number (read-only)
Number of rows actually visible in the itemsControl

Overrides:

showHeaders

public showHeaders: Boolean (read, write)
A Boolean value that indicates whether the data grid displays the column headers (true) or not (false).

sortableColumns

public sortableColumns: Boolean (read, write)
A Boolean value that indicates whether the columns are sortable (true) or not (false).

Boolean value that determines whether the columns of the data table can be sorted (true) or not (false) when a user clicks the column headers.
This property must be true for individual columns to be sortable.
The default value is true.

statusbarHeight

public statusbarHeight: Number (read, write)
The height of the statusbar.

statusbarMessage

public statusbarMessage: String (read, write)
Gets/Sets the display message in the statusbar

titlebarHeight

public titlebarHeight: Number (read, write)
The height of the titlebar

titlebarMessage

public titlebarMessage: String (read, write)
Gets/Sets the display message in the titlebar

viewportPixelHeight

public viewportPixelHeight: 0 (read-only)
The height of the viewable window--override to allow for header footer

Overrides:

viewportTop

public viewportTop: 0 (read-only)
The location of the top of the viewport

Overrides:


Constructor Documentation

DataGrid

public function DataGrid()
Constructor - This should not be called directly.

If you want to dynamically create a new instance of a control use its static newInstance method


Method Documentation

addColumn

public function addColumn(colName: Object,
 colTitle: String,
 colWidth: String): Column
Adds a columns to this DataGrid

Parameters:
colName
The path or name of a field in the datasource to bind to. Alternatively can also be a Column object
colTitle
The column title
colWidth
The column width
Returns:
The column object added

See also:

addColumnAt

public function addColumnAt(index: Number,
 colName: Object,
 colTitle: String,
 colWidth: String): Column
Adds a columns to this DataGrid

Parameters:
index
colName
The path or name of a field in the datasource to bind to. Alternatively can also be a Column object
colTitle
The column title
colWidth
The column width
Returns:
The column object added

See also:

addColumns

public function addColumns(cols: Array): Void
Adds a set of columns to this DataGrid columns set.

Parameters:
cols
An array of column objects

calculateWidths

public static function calculateWidths(columns: Array,
 width: Number): Array
Converts preferred widths into actual pixels

Each master column contains the specification of a preferred width.
This may be in absolute pixels or relative % width i.e. 20% or 150.
One column may be set to fill all remaining available space by setting its width specification to "*".
These preferred widths need to be converted into actual pixels based on the total available row width before being used to layout a row.
This is handled automatically by the system and should not need to be called directly.

Parameters:
columns
An array of master columns.
width
The total row width.
Returns:
The master columns array with the actual column widths set.

generateItemUI

public function generateItemUI(): Object
Generates an item UI for this items control

Called by host when databound to add empty items to the control

Usage:
This is called automatcially, do not use directly!

getClass

public function getClass(): Function
Returns a reference to the components static class

Overrides:

getColumn

public function getColumn(name: String): Column
Gets a reference to the Column object with the specified name.

Parameters:
name
The iname of the Column object to be returned.
Returns:
A Column object.

getColumnAt

public function getColumnAt(index: Number): Column
Gets a reference to the Column object at the specified index.

Parameters:
index
The index of the Column object to be returned. This number is zero-based.
Returns:
A Column object.

getColumnIndex

public function getColumnIndex(columnName: String): Column
Returns the index of the column specified by the columnName parameter.

Parameters:
columnName
A string that is the name of a column.
Returns:
A number that specifies the index of the column.

hideEditor

public function hideEditor(save: Boolean): Boolean
Hides the cell editor, called on a cellPress

Overrides:

newInstance

public static function newInstance(owner,
 instanceId,
 depth,
 initObj)
Creates a new Instance of this class

Creates an instance of a component at runtime. You need to use the import statement and specify the class package name before calling this method. In addition, the component must be in the FLA file’s library.

Parameters:
owner
A reference to the movie clip or object that will contains the new Instance.
instanceId
A string indicating the instance name of the new instance.(optional)
depth
A number indicating the depth of the new instance.(optional)
initObj
An object containing initialization properties for the new instance.(optional)
Returns:
A object that is an instance of the specified class.

onSetFocus

public function onSetFocus(oldFocus: Object): Void
SetFocus handler.Called when you get focus. If focus is actualy set to some internal TextField that TextField must call onSetFocus when it gets focus.

Overrides:

removeAllColumns

public function removeAllColumns(): Void
Removes all Columns from the target DataGrid instance.

removeColumnAt

public function removeColumnAt(index: Number): Column
Removes the Column instance at the given index.

Parameters:
index
The index of the column to remove
Returns:
the removed column

resetColumns

public function resetColumns(): Void
Clears all data rows, then reinitialises the columns and reloads the data

resizeColumn

public function resizeColumn(index: Number,
 inc: Number): Void
Resizes a column

Usually called by a header cell when a column has been resized by the user

Parameters:
index
The index of the column to be resized
inc
The number of pixels to increase or decrease the current width by

scrollInView

public function scrollInView(itemIndex: Number,
 columnIndex: Number)
Scrolls the ItemsControl so the specified row and cell are in view

Parameters:
itemIndex
The index of the target row .
columnIndex
The index of the target cell (optional) .

selectRowForEditing

public function selectRowForEditing(itemIndex: Number): Void
Callback handler called when the editor has finished editing the current row

Parameters:
itemIndex
row - row index of the cell to be edited.

setScrollContentHPos

public function setScrollContentHPos(pos): Void
Sets the horizontal scroll position

Internal callback from the ScrollTarget. Do not call directly, use scrollInView.

Overrides:

Parameters:
pos
The horizontal scroll position in pixels.

showEditor

public function showEditor(itemIndex: Number,
 columnIndex: Number): Boolean
Shows the cell editor row

Overrides:

Parameters:
itemIndex
- row index of the cell to be edited.
columnIndex
- column index of the first cell to be edited.

sortRows

public function sortRows(columnIndex: Number): Void
Sort the rows of the DataGrid

Parameters:
columnIndex
The index of the column to sort on

updateVirtualRows

public function updateVirtualRows(start: Number,
 end: Number): Void
Update the data for the visible rows in the list

Updates row objects by refreshing their dataSource with data from the itemsSource. It will also adjust the position and visibility of rows as needed. After the rows are updated, it will call the body to update itself and refresh the scrollbars This is called automatically by the system and should not be called manually

Parameters:
start
The index of the first row to update
end
The index of the last row to update

The documentation was generated from the following file:


Generated on 10/30/2005 9:34:02 PM by AS2Doc