Table column, filter and sort reference for App Engine
The properties of table columns in App Engine scripts, the filter operators, the sort options and the keyboard handlers.
POSTED: | UPDATED: | by Stefan Schüttenkopf
This page lists the properties of the columns of a table in an App Engine script, and the options for filtering and sorting. It applies to version 17.2. How to create and mount a table is described in Table configuration in AppEngine.
Column types
Each entry of columns describes one column. Its type decides how the values are shown, sorted and filtered.
type | Use for |
|---|---|
string | Text. This is the default. |
number | Numbers. |
date | Dates. |
dateTime | Dates with time. |
boolean | Yes / no values. |
singleSelect | Values from a fixed list. Give the list in valueOptions. |
custom | Values that you format yourself. |
Column properties
| Property | Type | Required | Default | Description |
|---|---|---|---|---|
field | keyof T | yes | The key of the row object whose value the column shows. | |
type | string | no | 'string' | The column type, see above. |
headerName | string | no | The text of the column header. | |
align | 'inherit' | 'left' | 'center' | 'right' | 'justify' | no | 'left' | The alignment of the cell content. |
hideable | boolean | no | true | Whether the user can hide the column in the settings. |
filterable | boolean | no | true | Whether the column is offered in the filter. |
valueOptions | Array<string | number> | no | The values of a singleSelect column. | |
valueFormatter | (value) => string | no | Formats the value for display. | |
transform | (row) => string | number | no | Computes the value of the cell from the row. The result is used for display, sorting and filtering. | |
grouping | boolean | no | true | Only for number columns: whether thousands separators are shown. |
columns: [
{ field: 'name', headerName: 'Name', type: 'string' },
{ field: 'area', headerName: 'Area [m²]', type: 'number', align: 'right', grouping: true },
{ field: 'status', headerName: 'Status', type: 'singleSelect', valueOptions: ['open', 'closed'] },
{ field: 'created', headerName: 'Created', type: 'dateTime', hideable: false }
]
Filter
The property filter sets the filter of the table, and the method setFilter changes it later. A filter is an object with one entry per column. The value is either the value to compare with or an object with these properties:
| Property | Type | Required | Description |
|---|---|---|---|
value | a value or an array of values | yes | The value to compare with. |
operator | FilterOperator | no | How to compare. See the operators below. |
transform | (row) => string | number | no | Computes the value to compare from the row. |
AND | a filter or an array of filters | no | Further conditions that must also be met. |
OR | a filter or an array of filters | no | Alternative conditions. |
| For | Operators |
|---|---|
| Text | like, caseinsensitiveLike, contains, doesNotContain, equals, doesNotEqual, startsWith, endsWith, isEmpty, isNotEmpty |
| Numbers | ==, !=, <, >, <=, >=, isEmpty, isNotEmpty |
| Dates | is, isNot, isAfter, isOnOrAfter, isBefore, isOnOrBefore, isEmpty, isNotEmpty |
| Lists | isIn, isNotIn |
filter: {
name: {
value: 'park',
operator: 'contains',
AND: { status: 'open' }
}
}
This shows the rows whose name contains park and whose status is open.
Sort
The property sort sets the order of the rows, and the method setSort changes it later. It is an array, so you can sort by several columns.
| Property | Type | Required | Default | Description |
|---|---|---|---|---|
key | keyof T | yes | The key of the row object to sort by. | |
order | 'asc' | 'desc' | no | 'asc' | Ascending or descending. |
transform | (row) => string | number | no | Computes the value to sort by from the row. |
sort: [
{ key: 'status' },
{ key: 'created', order: 'desc' }
]
Keyboard
With hotKeys you react to the Enter and the Escape key.
| Property | Type | Description |
|---|---|---|
enter | false | (() => void) | Called when the user presses Enter. false switches the key off. |
escape | false | (() => void) | Called when the user presses Escape. false switches the key off. |
Row click
onRowClick is called with the row object when the user clicks a row. Use it, for example, to open a form for that row.
onRowClick: (row) => {
console.log('Clicked', row.id);
}