DataTableView

Overview

The DataTableView represents customized view of a DataTable for sorting, filtering, grouping and navigation.

It is usuallly used to output table data in UI. By default if is created with the DataViewRowState flag set to Current which means that only currently visible rows from the table will be included in the view. But you can create the view to represent few other states, check DataViewRowState enum description for more info.

The DataTableView can also be subscribed to track changes of the DataTable. To do it, you need to register on DataTable's TableChangedEvent. But please consider a performance impact of this, because every modification of the table's data or structure will lead to view's state invalidating hence forces its entire refresh. The alternative is to ommit subscribtion to table's notifications and to force view's update manually by calling its refresh method. You can aslo manage refresh process with AutoRefresh property - if set to false refresh won't be called on every tableChanged notification.

Location

Implements

Instance Methods


constructor

 

constructor

 

DataTableView()

constructor (DataTable)

Creates an instance of a DataTableView class tied to a given DataTable object and DataViewRowState flag set to Current.

 

constructor(aTable: DataTable)

 

DataTableView(DataTable aTable)

Parameters:

  • aTable: A table to view. IllegalArgumentException is raised if table hasn't been given.

constructor (DataTable, DataViewRowState)

Creates an instance of a DataTableView class tied to a given DataTable object using the given DataViewRowState flag.

 

constructor(aTable: DataTable; aViewRowState: DataViewRowState)

 

DataTableView(DataTable aTable, DataViewRowState aViewRowState)

Parameters:

  • aTable: A table to view. IllegalArgumentException is raised if table hasn't been given.
  • aViewRowState: A mode state of rows the newly created view will hold.

filterAndSort (Filter, String[], Boolean[]): List<DataRow>

 

method filterAndSort(aFilter: Filter; aColumnNames: array of String; anAscArray: array of Boolean): List<DataRow>

 

List<DataRow> filterAndSort(Filter aFilter, String[] aColumnNames, Boolean[] anAscArray)

Parameters:

  • aFilter:
  • aColumnNames:
  • anAscArray:

filterAndSort (Filter, Comparator<DataRow>): List<DataRow>

 

method filterAndSort(aFilter: Filter; aComparator: Comparator<DataRow>): List<DataRow>

 

List<DataRow> filterAndSort(Filter aFilter, Comparator<DataRow> aComparator)

Parameters:

  • aFilter:
  • aComparator:

filterAndSort (Filter, String, Boolean): List<DataRow>

 

method filterAndSort(aFilter: Filter; aColumnName: String; anAsc: Boolean): List<DataRow>

 

List<DataRow> filterAndSort(Filter aFilter, String aColumnName, Boolean anAsc)

Parameters:

  • aFilter:
  • aColumnName:
  • anAsc:

filterDataRows

 

method filterDataRows(aFilter: Filter): List<DataRow>

 

List<DataRow> filterDataRows(Filter aFilter)

Parameters:

  • aFilter:

getAutoRefresh

Returns whether the view is auto refreshed or not.

The **AutoRefresh ** property defines whether or not a content of the view should be recalculated on TableChangedListener notification.

 

method getAutoRefresh: Boolean

 

Boolean getAutoRefresh()

getCount

Returns the number of rows currently refferenced by the view.

 

method getCount: Integer

 

Integer getCount()

getFilter

Returns the Filter used every time on a DataTableView's content refresh.

 

method getFilter: DataTableView.Filter

 

DataTableView.Filter getFilter()

getRow

Returns a row by the given index in the view.

 

method getRow(aIndex: Integer): DataRow

 

DataRow getRow(Integer aIndex)

Parameters:

  • aIndex: An index within the current view. Should be less than result of getCount.

getSorting

Returns the Comparator instance used every time on a DatatableView's content refresh.

 

method getSorting: Comparator<DataRow>

 

Comparator<DataRow> getSorting()

getTable

Returns the related table of the view.

 

method getTable: DataTable

 

DataTable getTable()

group<T>

 

method group<T>(aKeyEvaluator: KeyEvaluator<T>): Map<T, List<DataRow>>

 

Map<T, List<DataRow>> group<T>(KeyEvaluator<T> aKeyEvaluator)

Parameters:

  • aKeyEvaluator:

intCreateComparator

 

method intCreateComparator(aTable: DataTable; aComparator: Comparator<DataRow>): Comparator<Integer>

 

Comparator<Integer> intCreateComparator(DataTable aTable, Comparator<DataRow> aComparator)

Parameters:

  • aTable:
  • aComparator:

intGetRow

 

method intGetRow(aIndex: Integer): DataRow

 

DataRow intGetRow(Integer aIndex)

Parameters:

  • aIndex:

intSetFilter

 

method intSetFilter(aFilter: Filter)

 

void intSetFilter(Filter aFilter)

Parameters:

  • aFilter:

intSetSorting

 

method intSetSorting(aComparator: Comparator<DataRow>)

 

void intSetSorting(Comparator<DataRow> aComparator)

Parameters:

  • aComparator:

refresh

Forses to rebuild index of the current view. Call this method when you haven't subscribed on table's events and you know, that table has been changed.

 

method refresh

 

void refresh()

setAutoRefresh

Sets whether the view is auto refreshed or not.

The **AutoRefresh ** property defines whether or not a content of the view should be recalculated on TableChangedListener notification.

 

method setAutoRefresh(value: Boolean)

 

void setAutoRefresh(Boolean value)

Parameters:

  • value: The new value to be set.

setFilter

Sets a Filter to be used every time on a DataTableView's content refresh.

Note: Set it, if you want your data always be filtered according to some rule.

 

method setFilter(aValue: Filter)

 

void setFilter(Filter aValue)

Parameters:

  • aValue: The new Filter object to be set.

setSorting (String[], Boolean[])

This method is a helper method over Sorting property setter. It allows you to avoid creating Comparator if you want to sort the view by several columns with no extra data manipulation.

 

method setSorting(aColumnNames: array of String; anAscArray: array of Boolean)

 

void setSorting(String[] aColumnNames, Boolean[] anAscArray)

Parameters:

  • aColumnNames: A set of column names to use during sorting.
  • anAscArray: A set of sorting directions: TRUE - for ascending sorting; FALSE- for descending.

setSorting (Comparator<DataRow>)

Sets a Comparator implementation to be used every time on a DataTAbleView's content refresh.

Set it, if you want your data always be sorted according to some rule.

 

method setSorting(value: Comparator<DataRow>)

 

void setSorting(Comparator<DataRow> value)

Parameters:

  • value: A comparator to hold and use inside view.

setSorting (String, Boolean)

This method is a helper method over Sorting property setter. It allows you to avoid creating Comparator if you want to sort the view by one column.

 

method setSorting(aColumnName: String; anAsc: Boolean)

 

void setSorting(String aColumnName, Boolean anAsc)

Parameters:

  • aColumnName: A column name to use during sorting.
  • anAsc: Direction of sorting: TRUE - for ascending sorting; FALSE- for descending.

sort (String[], Boolean[]): List<DataRow>

This method is a helper over sort(Comparator). It allows you to avoid manually creating Comparator if you want to sort the view by several columns with no extra data manipulation.

 

method sort(aColumnNames: array of String; anAscArray: array of Boolean): List<DataRow>

 

List<DataRow> sort(String[] aColumnNames, Boolean[] anAscArray)

Parameters:

  • aColumnNames: A set of column names to use during sorting.
  • anAscArray: A set of sorting directions: TRUE - for ascending sorting; FALSE- for descending.

sort (Comparator<DataRow>): List<DataRow>

Sorts the contents of the current DataTableView and returns a list of sorted rows. Comparator object is not saved internally and doesn't affect on DataTableView state.

 

method sort(aComparator: Comparator<DataRow>): List<DataRow>

 

List<DataRow> sort(Comparator<DataRow> aComparator)

Parameters:

  • aComparator: A comparator to use.

sort (String, Boolean): List<DataRow>

This method is a helper over sort(Comparator). It allows you to avoid manually creating Comparator if you want to sort the view by single column with no extra data manipulation.

 

method sort(aColumnName: String; anAsc: Boolean): List<DataRow>

 

List<DataRow> sort(String aColumnName, Boolean anAsc)

Parameters:

  • aColumnName: A column name to use during sorting.
  • anAsc: Direction of sorting: TRUE - for ascending sorting; FALSE- for descending.

tableChanged

The method implements TableChangedListener and forces refresh of view's index if AutoRefresh property is set to TRUE.

 

method tableChanged(anEvent: TableChangedEvent)

 

void tableChanged(TableChangedEvent anEvent)

Parameters:

  • anEvent: An event occured.

See Also