doc/src/ComponentReference/contrib.Table.html [95:210]: - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
There are many ways to provide the component with the data it has to render, but here are the three major ones:
source
parameter in the form of an array,
a collection, or an iterator, and the table columns are defined using the
columns
parameter (see further for details).
Both of these parameters will be evaluated at every request by default,
so changes in the data or the table columns will be displayed immediately.
The example below uses this method.
This is the easiest and most straightforward approach. It has one performance limitation, however - if the table is sorting the data according to a given column, the sorting will be performed at every request. The next methods provide ways to resolve this possible performance issue.
source
parameter via an object that
implements the IBasicTableModel
interface. Through that interface you are given the sorting column (if any) and
the numbers of the items that will be displayed on the current page.
You then need to provide the component with the corresponding data.
This method allows you to perform the sorting in the database and load only the data that will be displayed on the current page (e.g. by using the ORDER BY, LIMIT, and OFFSET clauses in SQL) and hence it could be far more efficient.
ITableModel
and is passed to the tableModel
parameter.
This approach allows greatest flexibility, but is recommended only for advanced users of the Table components.
If you define the table columns using the columns
parameter, you can either
provide a list of ITableColumn
objects, each defining a column in the table, or you can define the columns using
a string that describes each column.
Please see the example below as a demonstration of the use of the latter approach.
The string describing the columns must be formatted in the following way:
Each column definition may be prefixed by the ! character, which identifies the column as non-sortable.
If defined, a Block with a name that is starts with the column id and ends with ColumnValue will be used to render the column values. Similarly, a Block with a name that starts with the column id and ends with ColumnHeader will be used to render the column headers.
Finally, the title of the column will be taken from translation strings of the component by using the column id as a key.
Please see the LocaleSelection component for examples.
ITableColumn
object defining the column.
Here is an example of the use of a description string to define columns:
columns="locale:toString(), =currencyColumn, verbosity:Verbosity:currentRowVerbosity, !delete"
There are many ways to provide the component with the data it has to render, but here are the three major ones:
source
parameter in the form of an array,
a collection, or an iterator, and the table columns are defined using the
columns
parameter (see further for details).
Both of these parameters will be evaluated at every request by default,
so changes in the data or the table columns will be displayed immediately.
The example below uses this method.
This is the easiest and most straightforward approach. It has one performance limitation, however - if the table is sorting the data according to a given column, the sorting will be performed at every request. The next methods provide ways to resolve this possible performance issue.
source
parameter via an object that
implements the IBasicTableModel
interface. Through that interface you are given the sorting column (if any) and
the numbers of the items that will be displayed on the current page.
You then need to provide the component with the corresponding data.
This method allows you to perform the sorting in the database and load only the data that will be displayed on the current page (e.g. by using the ORDER BY, LIMIT, and OFFSET clauses in SQL) and hence it could be far more efficient.
ITableModel
and is passed to the tableModel
parameter.
This approach allows greatest flexibility, but is recommended only for advanced users of the Table components.
If you define the table columns using the columns
parameter, you can either
provide a list of ITableColumn
objects, each defining a column in the table, or you can define the columns using
a string that describes each column.
Please see the example below as a demonstration of the use of the latter approach.
The string describing the columns must be formatted in the following way:
Each column definition may be prefixed by the ! character, which identifies the column as non-sortable.
If defined, a Block with a name that is starts with the column id and ends with ColumnValue will be used to render the column values. Similarly, a Block with a name that starts with the column id and ends with ColumnHeader will be used to render the column headers.
Finally, the title of the column will be taken from translation strings of the component by using the column id as a key.
Please see the LocaleSelection component for examples.
ITableColumn
object defining the column.
Here is an example of the use of a description string to define columns:
columns="locale:toString(), =currencyColumn, verbosity:Verbosity:currentRowVerbosity, !delete"