class GridView
package feathers.controls
extends BaseScrollContainer › FeathersControl › MeasureSprite › ValidatingSprite
implements IDataSelector<Dynamic>, IIndexSelector
Displays a list of items as a table. Each item is rendered as a row, divided into columns for each of the item's fields. Supports scrolling, custom cell, sorting columns, resizing columns, and drag and drop re-ordering of columns.
The following example creates a grid view, gives it a data provider, tells the columns how to interpret the data, and listens for when the selection changes:
var gridView = new GridView();
gridView.dataProvider = new ArrayCollection([
{ item: "Chicken breast", dept: "Meat", price: "5.90" },
{ item: "Butter", dept: "Dairy", price: "4.69" },
{ item: "Broccoli", dept: "Produce", price: "2.99" },
{ item: "Whole Wheat Bread", dept: "Bakery", price: "2.49" }
]);
gridView.columns = new ArrayCollection([
new GridViewColumn("Item", (data) -> data.item),
new GridViewColumn("Department", (data) -> data.dept),
new GridViewColumn("Price", (data) -> data.price)
]);
gridView.addEventListener(Event.CHANGE, (event:Event) -> {
var gridView = cast(event.currentTarget, GridView);
trace("GridView changed: " + gridView.selectedIndex + " " + gridView.selectedItem.item);
});
this.addChild(gridView);
1.0.0
.See also:
Static variables
staticfinalread onlyCHILD_VARIANT_HEADER:String = "gridView_header"
The variant used to style the column headers in a theme.
1.0.0
.See also:
staticfinalread onlyVARIANT_BORDER:String = "border"
A variant used to style the grid view with a border. This variant is used by default on desktop.
The following example uses this variant:
var gridView = new GridView();
gridView.variant = GridView.VARIANT_BORDER;
1.0.0
.See also:
staticfinalread onlyVARIANT_BORDERLESS:String = "borderless"
A variant used to style the grid view without a border. The variant is used by default on mobile.
The following example uses this variant:
var gridView = new GridView();
gridView.variant = GridView.VARIANT_BORDERLESS;
1.0.0
.See also:
Constructor
Variables
allowMultipleSelection:Bool
Determines if multiple items may be selected at the same time. Has no
effect if selectable
is false
.
In the following example, multiple selection is enabled:
gridView.allowMultipleSelection = true;
1.0.0
.See also:
cellRendererRecycler:DisplayObjectRecycler<Dynamic, GridViewCellState, DisplayObject>
Manages cell renderers used by the grid view.
In the following example, the grid view uses a custom cell renderer class:
gridView.cellRendererRecycler = DisplayObjectRecycler.withClass(CustomCellRenderer);
1.0.0
.columnResizeSkin:DisplayObject
The skin to display when a column is being resized.
1.0.0
.See also:
columns:IFlatCollection<GridViewColumn>
Defines the set of columns to display for each item in the grid view's
data provider. If null
, the grid view will attempt to populate the
columns automatically using
reflection.
The following example passes in a data provider and tells the columns how to interpret the data:
gridView.dataProvider = new ArrayCollection([
{ item: "Chicken breast", dept: "Meat", price: "5.90" },
{ item: "Butter", dept: "Dairy", price: "4.69" },
{ item: "Broccoli", dept: "Produce", price: "2.99" },
{ item: "Whole Wheat Bread", dept: "Bakery", price: "2.49" }
]);
gridView.columns = new ArrayCollection([
new GridViewColumn("Item", (data) -> data.item),
new GridViewColumn("Department", (data) -> data.dept),
new GridViewColumn("Price", (data) -> data.price)
]);
1.0.0
.See also:
dataProvider:IFlatCollection<Dynamic>
The collection of data displayed by the grid view.
The following example passes in a data provider and tells the columns how to interpret the data:
gridView.dataProvider = new ArrayCollection([
{ item: "Chicken breast", dept: "Meat", price: "5.90" },
{ item: "Butter", dept: "Dairy", price: "4.69" },
{ item: "Broccoli", dept: "Produce", price: "2.99" },
{ item: "Whole Wheat Bread", dept: "Bakery", price: "2.49" }
]);
gridView.columns = new ArrayCollection([
new GridViewColumn("Item", (data) -> data.item),
new GridViewColumn("Department", (data) -> data.dept),
new GridViewColumn("Price", (data) -> data.price)
]);
1.0.0
.See also:
headerRendererRecycler:DisplayObjectRecycler<Dynamic, GridViewHeaderState, DisplayObject>
Manages header renderers used by the grid view.
In the following example, the grid view uses a custom header renderer class:
gridView.headerRendererRecycler = DisplayObjectRecycler.withClass(CustomHeaderRenderer);
1.0.0
.resizableColumns:Bool
Determines if the grid view's columns may be resized by mouse/touch.
The following example enables column resizing:
gridView.resizableColumns = true;
See also:
selectable:Bool
Determines if items in the grid view may be selected. By default only a single item may be selected at any given time. In other words, if item A is already selected, and the user selects item B, item A will be deselected automatically.
The following example disables selection of items in the grid view:
gridView.selectable = false;
See also:
selectedIndices:Array<Int>
Contains all of the indices that are currently selected. The most recently selected index will appear at the beginning of the array. In other words, the indices are in the reverse order that they were selected by the user.
When the selectedIndices
array contains multiple items, the
selectedIndex
property will return the first item from
selectedIndices
.
1.0.0
.See also:
selectedItems:Array<Dynamic>
Contains all of the items that are currently selected. The most recently selected item will appear at the beginning of the array. In other words, the items are in the reverse order that they were selected by the user.
When the selectedItems
array contains multiple items, the
selectedItem
property will return the first item from selectedItems
.
1.0.0
.See also:
virtualLayout:Bool
Indicates if the grid view's layout is allowed to virtualize items or not.
The following example disables virtual layouts:
gridView.virtualLayout = false;
1.0.0
.Methods
columnToHeaderRenderer(column:GridViewColumn):DisplayObject
Returns the current header renderer used to render a specific column.
1.0.0
.See also:
headerRendererToColumn(headerRenderer:DisplayObject):GridViewColumn
Returns the current column that is rendered by a specific header renderer.
1.0.0
.See also:
scrollToRowIndex(rowIndex:Int, ?animationDuration:Float):Void
Scrolls the grid view so that the specified row is completely visible. If the row is already completely visible, does not update the scroll position.
A custom animation duration may be specified. To update the scroll
position without animation, pass a value of 0.0
for the duration.
@since 1.0.0