My FNZ Studio Version

Screen-Driven Model

Latest Update: 25.11.2020 | , Margherita Taffarel
Documentation
2024
2023
2022.2
2022.1
11
10
9
8
7
6.3

1 Introduction

The Data Table is a Screen component that displays data in a table. It allows data sorting and filtering with minimal resource requirements.

This document uses a list of movie titles as an example of how to set up a Data Table. The table has multiple columns, one of which is an action column. This action column allows users to execute certain functions on a movie. The table is sortable and filterable. By clicking on a row, the table displays an interline revealing more detailed information about each movie.

Introduction-1.png

2 Components

A Data Table has three different screen components to allow maximum flexibility for during configuration.

2.1 Data Table

This is the root component of a Data Table. It defines a data source and the overall rendering behavior. The table can be rendered using a scrollbar or with a pager.

The Data Table also defines which screen to render as the interlining content of the table – and whether to display an interline at all.

2.2 Data Column

This is a direct child of a Data Table. Add a Data Column to the Data Table for each column you want the table to render. On each column, configure its width, a header label and some styling, set up Filters, Sorters and Cell-Editors on this component.

Note: The exact availability of configuration options depends on the setting made in the Source field of the Data Table component (see the Data Sources section for more details).

2.3 Data Content

This component defines which portion of data provided by the table's data source is displayed in a cell. Each Data Content can have its own text and/or icon, styling and actions. This way, you are able to create content for a cell that has multiple parts, like two icons and a text.

Of course, actions can be applied to whole rows, cells or content only. Please refer to Actions chapter below.

3 Data Source

This is configured in the Data Table component and is usually the first thing to do when creating a new table. There are four kinds of data sources you can choose from: Catalog, Expression, or Data Class.

3.1 Catalog

This is the simplest way of setting up a data source for a Data Table. In the movie table example, a static catalog is used to define a column for each movie property.

Catalog-1.png

In the Screen Editor, drag a Data Table to the display area and choose "Catalog" as the "Source". Then, use the "Source Catalog" dropdown to look for the appropriate catalog you want to use. An important step is to set the "Row Object Variable". This defines the name of the variable, which will hold a reference to the catalog record processed when rendering a row in the Data Table. Use this variable when setting up cell content or when defining actions for a specific row.

Catalog-2.png

The next step is to add a Data Column for each column you want to display in the table. The number of columns or their semantic meaning does not have to match the columns of the catalog. You can create any column you want by using the catalog's data and then create another column out of it.

For example, for a table of users, it is easy to create a column that shows each user's full name (first and last name) even though the underlying user object may not contain a property for that. Simply concatenate the user's first and last name within a single column.

Catalog-3.png

For now, it is enough to merely set the label for each column. A standard filter and a standard sorter are automatically attached to each column. The columns' width is also set automatically but can be tweaked later.

Next, tell the table what it should display in the columns by adding a Data Content element to each column. It has a property called "Text", in which the "Row Object Variable" can be used. This variable's name was previously defined in the Data Table component.

Catalog-4.png

Each time a row is rendered, all of the attached Data Content components are rendered as well. This means that what you define in the property Text of a Data Content component is written to the cells of its column. In the example, to fill the first column with movie titles, the title that is stored in each catalog record is accessed. Use the Row Object Variable $movie which, in the case of a catalog, represents the record currently processed. To access the title column of this record, use the function $movie.getValue('title').

Repeating this for each column, the result is a table that shows all of the movies defined in the catalog:

Expression-3.png

3.2 Expression

Using an Expression as a data source returns a collection of custom-defined objects rather than Records. In the movie example, define a Data Class "Movie" as follows:

Expression-1.png

Assume that there is an indexed collection of the "Movies" Data Class within the process with the same movies as in the catalog above.

Set the Data Table's source to "Expression." This shows a property called "Source Collection" that is set so that it points to the indexed collection of movies just mentioned. As in the catalog setup, define a Row Object Variable. Set this variable's type and collection type since Appway does not automatically know which one is the row object's type. Thus, set the Row Object Type property to "Movie" and the Row Object Collection to "Single Element". Each object in the collection is of type "Movie" and is a single element.

Expression-2.png

Since these are instances of "Movie" instead of catalog records, you cannot use $movie.getValue() to get the values for the Data Content. Instead, the Data Class "Movie" provides properties for each value. Set the text property of each Data Content to $movie.title, $movie.year and $movie.genre respectively, as depicted in the picture above.

The result is the same table as the one built using a catalog as the data source in the previous section. However, this table accesses data using an expression collection.

Expression-3.png

3.3 Data Class

For a very large amount of data, create a Data Table model with a Data Class. This model is in charge of fetching, filtering and sorting the data. This way, you are able to optimize the tasks according to your data provider.

3.3.1 Using a Data Class

Using an existing Data Class that serves as a model is as easy as using an expression for the source. The image below shows a Data Table that references a Data Class. Apart from the Row Object Variable, the Data Class is the only mandatory property that needs to be set. The type and collection type of the row object is determined by using the function describe() of the Data Class. There is no need to set it here.

DataClass-1.png

The Data Class is instantiated by Appway as soon as the table is rendered. Unfortunately, it is not possible to store the instance in a variable to directly access it in other parts of the screen. This is due to the complex lifecycle of a Data Table model. However, to access properties or functions of the model, use the built-in function “DataTableModel”.

The function “DataTableModel” returns the instance of a Data Class that serves as a model for a particular Data Table. To identify the model, use its ID that you can bind to any variable using the property “Model Id Binding” shown above. The ID is bound to the specified variable as soon as the Data Table is rendered and thus, the Data Class is instantiated.

DataTableModel($type, $id)
Parameter Description
$type
Any
The type of the data class
Example: DBTableModel
$id
String
The id of the model
Example: $modelId
Return value Description
Any The instance of the data class

Example:

DBTableModel $model := DataTableModel(DBTableModel, $modelId)

Important: Since an instance of a Data Class returned by “DataTableModel” is not part of a PageContext and uses its own execution context, it must not be bound to a variable defined on screen level (Local, Inherited, Assigned).
This means that whenever you want to access the model, call “DataTableModel”. You may, however, reference it in a script-local variable, a variable that lives for the execution of that particular script only.

A Data Class that serves as a model might need initial information when it is instantiated. Consult with the developer of the Data Class for this information. For example, it might be necessary to provide it with a database name that it should access. For this purpose, there is an additional property called ‘Model Initialization’. The script you provide in this property is executed immediately after the Data Class has been instantiated and thus, serves as a constructor for the Data Class. Again, in order to retrieve the instance of the Data Class, use the function “DataTableModel”.

DBTableModel $model := DataTableModel(DBTableModel, $modelId);
$model.dbName := some_db_name;

If you want to use filters and/or sorters in a Data Table that uses a Data Class, you have to reference a property, for which the Data Class explicitly supports filtering and/or sorting. For instance, in the following image, the first column shows the titles of the movies so set the reference to the corresponding value in order to tell the Data Class that this column refers to the title for filtering and sorting.

DataClass-2.png

The filtering and sorting of the data is delegated to the Data Class model. Depending on the Data Class, the filters and sorters are adjusted. For instance, not all Data Classes offer the possibility of wildcard text filtering, so this operation might not be provided in the UI.

3.3.2 Implementing a Data Class

A Data Table is never fully rendered. Only the relevant rows that the user currently sees are rendered. As the user scrolls, more rows are fetched from the server and displayed in the view. This makes it possible to display a table with an unlimited amount of rows as long as the server is capable of handling the amount.

A model does not configure any columns. It only serves row objects which can be used to build columns in the screen editor the same way you would when configuring a catalog or an expression as the data source. However, it is possible to describe the model in a way that will limit the possibilities provided to the screen developer and the end user of the table. Depending on the model, it is for example, possible to describe a column that only allows for a certain type of filter, and within that filter will only support a subset of operations and precisions (e.g., MATCH_CASE, IGNORE_CASE).

At the very least, a Data Class that serves as a model provides the “fetch” function. Additionally, it is possible to provide the “describe”, “filter” and “sort” functions.

3.3.3 Fetch (required)

Every time the data table loads rows from the server, it calls the function “fetch” on the model. Fetch does not return anything. Instead, it fills the given DataTableResultSet with row objects. Remember that a Data Table model does not fill columns; it only serves row objects that can be used to create columns in the Screen Editor.

The tricky part about “fetch” is that it has to fill the correct row objects into the result set. The Data Table indicates which of the rows have to be fetched with respect to the current sorter and filter settings by using the two other parameters ($start and $limit).

$start is the index of the first row that has to be filled into the result set. Be aware that row indices start with 0 (zero). $limit tells you how many rows have to be filled in at most. It is quite possible that the Data Table requests more rows than there actually are ($start + $limit > ‘total amount of rows’). It is the responsibility of the model to handle this and possibly not fill any rows into the result set.

A “fetch” also sets the current amount of filtered (and thus, visible) rows as well as the current total amount of rows. The Data Table needs this information so it knows how to render the vertical scrollbar or in case of a paged interaction, how to render the pager buttons. The result set offers two functions (“setVisibleCount” and “setTotalCount”) to set these values.

The following code fragment shows a very basic implementation of “fetch” that serves movies. Be aware, that the signature of the function must exactly match the one in the example. The Data Class will NOT be present as a source in the Screen Editor, if it differs in any way including the names of the parameters:

Function fetch(DataTableResultSet $rs, Integer $start, Integer $limit) : Nothing Begin 
   Integer $max := MIN($start + $limit, $this.movies.size());
   For Integer $i := $start Condition $i < $max Step $i := $i + 1 Do 
      $rs.row($movies.getElement($i + 1));
   End
   $rs.setVisibleCount($visibleCount);
   $rs.setTotalCount($totalCount);
End

3.3.4 Describe

This function provides information about its row object type and the capabilities of the model. While generally optional, this function is mandatory if you want the screen developer to be able to use filters and/or sorters. The Data Table component will only offer the filters and sorters that the model explicitly allows. As such, the developer of the model has full control over the possible filter and sorter settings that the model needs to be able to handle.

This function receives no parameters but returns an instance of DataTableDescription. A DataTableDescription holds all information about the model. Set it up with the following functions (use only the functions described here):

Function Description
setRowObjectType(String): Nothing Sets the script type of the row object
The model fills the DataTableResultSet with row objects, which will be used in the Screen Editor to build rows. With this function, it is possible to define the type of the row objects so the Screen Editor can provide intelligent code completion when the row object is used in the Script Editor.
Default: If you do not provide a row object type, it defaults to Any which is equivalent to calling:
$table.setRowObjectType(Any);
Example: If the row object is of type Movie, call:
$table.setRowObjectType(Movie);
setRowObjectCollection(String): Nothing Sets the script collection type of the row object
The model fills the DataTableResultSet with row objects which will be used in the Screen Editor to build rows. With this function, it is possible to define the collection type of the row objects so the Screen Editor is able to provide intelligent code completion when the row object is used in the Script Editor.
Default: If you do not provide a collection type, it defaults to Single Element which is equivalent to calling $table.setRowObjectCollection(‘none’); If the row object is an Indexed Collection, call:
$table.setRowObjectCollection(‘indexed’);
If the row object is an Named Collection, call:
$table.setRowObjectCollection(‘mapped’);
setSteady(Boolean): Nothing Declares whether the model is “steady” or “not steady”
A model is steady (default) if the currently loaded rows in the table do not have to be cleared with every fetch request. This means if the user scrolls the content or changes a page, and then returns to the previous scroll position or page, no new fetch request is made. Instead, the previously loaded rows will be displayed.
A model is not steady if the currently loaded rows in the table are always cleared when the user scrolls the content or changes a page. This results in a complete reload with every fetch request.
In any case, the table clears all rows and reloads the content if the number of visible rows or the number of total rows changes with a fetch request. This is a clear indicator that the data of the model has changed and thus, the currently loaded rows are no longer up-to-date.
Default: If you do not set this property, it defaults to steady which is equivalent to calling:
$table.setSteady(true);
If the model is not steady, call:
$table.setSteady(false);
createColumn(String): DataTableColumnDescription Create a column description for each column you want to provide information for. In the Screen Editor, define any number of columns regardless of the descriptions. But setting a filter and/or a sorter is only possible on columns that reference a description.
The first and only argument you have to provide to the function is the reference of the column. On a Data Column component in the Screen Editor, select one of the created column references. As soon as one is selected, the Screen Editor allows you to set filters and sorters that share the same reference.
Example: Let us say the model serves movies. To make it possible to define a column that will be filterable according to the title of the movie, define a column description for which the reference named ‘title’:
$table.createColumn(‘title’);
Note: The returned object, which is of type DataTableColumnDescription does not provide any function yet, since currently there is nothing to define but a column reference. The function still returns it, in case future releases allow for possible descriptive functions on a column.
createFilter(String, String): DataTableFilterDescription In the Screen Editor, select a filter type for columns that reference a DataTableColumnDescription.
With createFilter(),define what filter types you want to provide for a certain column description. If you do not create any filter description for a certain reference, it is not possible to set a filter on columns with that reference.
Example: Let us say the model serves movies and a DataTableColumnDescription is created with ‘title’ as its reference. To set a text filter for columns that reference that description:
$table.createFilter(‘title’, ‘Textfield’);
Possible filter types are:
  • Textfield
  • Numeric
  • Dropdown
  • Date Time
  • Boolean
The returned object is of type DataTableFilterDescription. Use it to further describe the supported features of the corresponding filter. Its functions are described in the next part of this chapter.
createSorter(String, String): DataTableSorterDescription In the Screen Editor, select a sorter type for columns that reference a DataTableColumnDescription.
With createSorter(),define what sorter types you want to provide for a certain column description. If you do not create any sorter description for a certain reference, it is not possible to set a sorter on columns with that reference.
Example: Let us say the model serves movies and a DataTableColumnDescription is created with ‘title’ as its reference. To set a text sorter for columns that reference that description:
$table.createSorter(‘title’, ‘Text’);
Possible sorter types are:
  • Text
  • Numeric
  • Boolean
Note: The returned object, which is of type DataTableSorterDescription does not provide any function yet, since currently there is nothing to define but a sorter type. The function still returns it, in case future releases allow for possible descriptive functions on a sorter.

A DataTableFilterDescription holds all information about a certain filter type for the column with the same reference. Set it up with the following functions (use only the functions described here):

Function Description
addSupportedOperation(Operation): Nothing A filter may support multiple operations according to its type. Not all models can or will implement all of them, so it is possible to define the supported operations.
The first and only parameter, Operation, is a Java enumeration. But it is still save to pass a string, which will be parsed into the corresponding enumeration type.
If you describe a text filter and the model supports the two operations ‘EQUALS’ and ‘CONTAINS’ on that filter, call: $filter.addSupportedOperation(‘EQUALS’);
$filter.addSupportedOperation(‘CONTAINS’);
Possible operations are:
  • EQUALS
  • CONTAINS
  • STARTS_WITH
  • ENDS_WITH
  • WILDCARD
  • EMTPY
  • GREATER_THAN
  • GREATER_THAN_OR_EQUAL
  • LOWER_THAN
  • LOWER_THAN_OR_EQUAL
  • RANGE
  • DURING_THE_LAST
Not all filter types support all operations. It would not make sense to use a text filter with the operation ‘DURING_THE_LAST’. If you set an operation to be supported but the filter type itself does not support it, it is simply ignored and not shown as an option on the Screen Editor.
addSupportedPrecision(Precision): Nothing A filter may support multiple precisions according to its type. Not all models can or will implement all of them, so it is possible to define the supported precisions. The first and only parameter, Precision, is a Java enumeration. It is still saved to pass a string, which will be parsed into the corresponding enumeration type. If you describe a text filter and the model supports the two precisions ‘MATCH_CASE and ‘IGNORE_CASE’ on that filter, call:
$filter.addSupportedPrecision(‘MATCH_CASE’);
$filter.addSupportedPrecision(’IGNORE_CASE’);
Possible precisions are:
  • MATCH_CASE
  • IGNORE_CASE
  • DAY
  • MINUTE
  • SECOND
  • MILLISECOND
Not all filter types support all precisions. It would not make sense to use a text filter with the precision ‘DAY’. If you set a precision to be supported but the filter type itself does not support it, it is simply ignored and not shown as an option on the Screen Editor.
setMaxLength(Integer): Nothing The text filter can limit the number of characters a user can type. This is handy if a model provides a text filter, but can only process a limited number of characters.
This function allows you to define the maximum number of characters the user can type in the text field of a text filter.
If you do not call this function, the amount will be ‘unlimited’.
Note: This function does not have any effect on filter types other than ‘Textfield’.

Depending on the capabilities of the model, this function can become very long. However, the developer has full control over the data the model has to process.

The following code is an example of the implementation of the function describe():

Function describe() : DataTableDescription Begin 
   DataTableDescription $table := NEW(DataTableDescription);
   DataTableFilterDescription $filter;
   //
   $table.setRowObjectType(Movie);
   //
   // describe the title property.
   $table.createColumn('title');
   $table.createSorter('title', 'Text');
   //
   $filter := $table.createFilter('title', 'Textfield');
   $filter.addSupportedOperation('EQUALS');
   $filter.addSupportedOperation('CONTAINS');
   $filter.addSupportedOperation('STARTS_WITH');
   $filter.addSupportedOperation('ENDS_WITH');
   $filter.addSupportedOperation('WILDCARD');
   //
   // describe the year property
   $table.createColumn('year');
   $table.createSorter('year', 'Numeric');
   //
   $filter := $table.createFilter('year', 'Numeric');
   $filter.addSupportedOperation('EQUALS');
   $filter.addSupportedOperation('GREATER_THAN');
   $filter.addSupportedOperation('LOWER_THAN');
   //
   // describe the genre property
   $table.createColumn('genre');
   $table.createSorter('genre', 'Text');
   //
   $filter := $table.createFilter('genre', 'Textfield');
   $filter.addSupportedOperation('EQUALS');
   $filter.addSupportedOperation('CONTAINS');
   $filter.addSupportedOperation('STARTS_WITH');
   $filter.addSupportedOperation('ENDS_WITH');
   $filter.addSupportedOperation('WILDCARD');
   //
   $filter := $table.createFilter('genre', 'Dropdown');
   $filter.addSupportedOperation('EQUALS');
   $filter.addSupportedOperation('CONTAINS');
   $filter.addSupportedOperation('STARTS_WITH');
   $filter.addSupportedOperation('ENDS_WITH');
   $filter.addSupportedOperation('WILDCARD');
   Return $table;
End

3.3.5 Filter (optional)

Whenever a filter value changes, the Data Table asks the server to filter the data by calling "filter" on the model immediately followed by calling "fetch".

The function “filter” must have the following signature. It will NOT be called, if it differs in any way including the name of the parameter:

Function filter(Indexed DataTableFilter $filters) : Nothing Begin

The Data Table provides "filter" with an indexed collection of DataTableFilter. The collection holds all filters that are currently active. It is, therefore, possible that "filter" will be called with an empty collection, which means that all filters have been reset.

It is up to the developer to decide whether it is appropriate to actually filter data in the "filter" function. Sometimes, it is better to only prepare something out of the filter properties. For instance, create an SQL fragment in the "filter" function and store it in a property of the Data Class. Later, the SQL fragment could be used by “fetch” to build a complete SQL statement every time it is called in order to execute a database request.

A DataTableFilter provides the following functions for use within "filter" (use only the functions described here):

Function Description
getValue(): Any Returns the current value of the filter. The type of the value depends on the type of filter. You can determine the type of the filter by using the getReference() method which is described below.
To determine if the value is a range or a simple value, use the method getOperation() which returns ‘RANGE’ for a range. This method is described below.
  • The value of a Textfield filter is a String.
  • The value of a Numeric filter is a Number or a Range of Numbers.
  • The value of a Dropdown filter is an Indexed String.
  • The value of a Date Time filter is a Date or a Range of Dates.
  • The value of a Boolean filter is a Boolean.
getReference(): String The model needs to know what data (column/property) the filter references (is applied for). For that purpose, the model can create a description for each filter it supports. Each filter description is defined with a reference for identification.
This function will return that reference, so it is possible to determine the data on which the filter value should be applied.
Note: See the documentation of the function describe() for more information on how to setup a filter description.
getOperation(): Operation Some filters support multiple operations that tell the model how to interpret the value of the filter. This function returns the currently set operation. The returned operation is a Java Enumeration type. Therefore, it is necessary to call toString() to get the actual operation.
String $operation := $filter.getOperation().toString();
Note: See the documentation of the function describe() for more information on the possible operations and how to limit support.
getPrecision(): PrecisionSome filters support multiple precisions that tell the model how precise the value of the filter should be interpreted. This function will return the currently set precision. The returned precision is a Java Enumeration type. Therefore, it is necessary to call toString() to get the actual precision.
String $precision := $filter.getPrecision().toString();
Note: See the documentation of the function describe() for more information on the possible precisions and how to limit their support.

3.3.6 Sort (optional)

Whenever a sort direction changes, the Data Table asks the server to sort the data by calling "sort" on the model immediately followed by calling "fetch".

The function “sort” must have the following signature. It will NOT be called, if it differs in any way including the name of the parameter:

Function sort(Indexed DataTableSorter $sorters) : Nothing Begin

The Data Table provides "sort" with an indexed collection of DataTableSorter. The collection holds all sorters that are currently active. It is, therefore, possible that the function is called with an empty collection, which means that all sorters have been reset.

Important: The order of the given sorters matters. Since the user is able to sort multiple columns by holding the shift key, it is also important that the data be sorted in that order of relevance.

It is up to the developer to decide whether it is appropriate to actually sort data in the "sort" function. Sometimes, it is better to only prepare something out of the sorter properties. For instance, create an SQL fragment in the "sort" function and store it in a property of the Data Class. Later, the SQL fragment could be used by “fetch” to build a complete SQL statement every time it is called in order to execute a database request.

A DataTableSorter provides the following functions for use within "sort" (use only the functions described here):

Function Description
getDirection(): Direction Returns the currently set direction. The returned direction is a Java Enumeration type. Therefore, it is necessary to call toString() to get the actual direction.
String $direction := $filter.getDirection().toString();
The possible values are:
  • ASC (for ascending order)
  • DESC (for descending order)
getReference(): String The model needs to know what data (column/property) the sorter references (is applied for). For that purpose, the model creates a description for each sorter it supports. Each sorter description is defined with a reference for identification.
This function will return that reference, so it is possible to determine the data on which the sorter direction should be applied.
Note: See the documentation of the function describe() for more information on how to set up a sorter description.

4 Actions

In a Data Table, it is possible to add

  • general actions
  • actions on rows
  • actions on cells
  • actions on individual content within a cell.

4.1 General Actions

A Data Table provides two general actions, which have to be defined on the Data Table component itself. Go to the Data Table's Actions tab.

  • oncount — Triggered when the visible row count or the total row count of the table has changed
  • onready — Triggered when the table has loaded its data for the first time
    Use this if you want to show information on the screen that is not available until the Data Table has been rendered and loaded. For instance, if the Data Table uses a Data Class that provides more information for display. The Data Class will not be instantiated until the Data Table has been rendered. If you still want to access the instance before that point, configure this action to execute an AjaxUpdateArea, which reloads the part of the screen for which the Data Class instance has not existed yet.

4.2 Actions on Rows

The possible actions on rows are “onclick” and “ondblclick”. Define them on the Data Table component itself. Go to the Data Table's Actions tab and use the row object variable.

4.3 Actions on Cells

Actions on cells are defined on Data Column components. Go to the Data Column's Actions tab and use the row object variable.

If defined in this way, an action available on a row will not be triggered if the user executes the action on the cell.

4.4 Actions on Content

If you place multiple Data Content components into a cell, you can set different actions for each of the content elements. You can set up multiple icons in a cell, each having its own action.

If defined in this way, an action available on a row or cell will not be triggered if the user executes the action on the content element.

4.5 Example

To create action triggers for deleting and editing, add another Data Column to the data table and place two Data Content elements in this column. For each of the Data Content elements, set an icon according to the action you want to provide.

Actions-1.png

Once the two icons are in place, use the Actions tab on each of the Data Content elements and add actions that fit the desired functionality. You can also access the row object variable when using the expression language within actions. Refer to the actual object for which the user executed the action. In the example, this means you already have a reference to the movie to be edited or deleted.

Actions-2.png

The table renders as shown below. The columns are equally sized which does not fit the content of the table very well. Refer to the "Layout" chapter to learn how to tweak the rendering.

Actions-3.png

5 Filters

Each column has its own filter. There are different types of filters to choose from, depending on the column data and what the user interface should render.

If a column should not be filterable, set the type of the filter to none. This will not render a filter and it will, therefore, not be possible for the user to enter anything. If none of the columns is filterable, the overall filter button disappears.

Filters-1.png

5.1 Property: Value

The "Value" defines a predefined filter value that is set at the time the Data Table is rendered. This way, you set what the user sees when the table is rendered for the first time. Of course, the user can change that value later.

5.2 Property: Index

This is the content of the cell that is used for filtering. It is used to decide whether a row is visible or not. Providing an index increases the performance when filtering the table.

Whenever the user filters for a certain column, the server has to iterate over all rows and decide if it has to be displayed or not. For each row, it checks all columns with an active filter. If a column has an active filter, it checks if an index is defined for that column. If an index is defined, it uses that index to let the filter check if it matches. If no index is defined, it renders the content of the cell. Then it tries to parse the content to a compatible type that the filter can handle. Then it lets the filter check if it matches.

When an index is set, the Data Table bypasses the rendering and parsing of the content of each cell by directly passing the corresponding index to the filter. This leads to a massive performance boost.

Example: You use a Date Time filter and you use a Data Class that has a property of type Date to be displayed in the cells. You can set the index to that date property. Like this the Data Table does not have to render the date object; it only parses it into a data object again for filtering.

While the index boosts performance, it also has a nice side effect: it allows you to manipulate how your filter works.

Take the example of a table of users. One column displays the role of the user. It shows "Administrator", "Member" or "Guest". The definition says that every administrator is also a member. You then want to provide a filter that will show administrators and members, if filtered for "Member".

For this kind of data, it is best to use a dropdown filter that will provide the three possible values. If you set the operation of the dropdown filter to "CONTAINS", then the filter also matches content for which the selected filter value is only a partial match. This means if the user selects "Administrator" in the dropdown, it would also match content like "Administrator,Member".

With the index, you can now define the content of the cell regarding filtering. If a user is rendered and is an administrator, the index has to be a string that will match both "Member" and "Administrator". It looks like this:

If $user.getType() == 'Administrator' Then 
   Return 'Administrator,Member';
Else
   Return $user.getType();
End

The cells for an administrator will render "Administrator" but when index filtering is used which says "Administrator,Member", the dropdown filter matches both because it uses the "CONTAINS" operation.

Note: The index property is not available for Data Tables that use a Data Class as their source, since filtering and sorting will be delegated to the corresponding model. Thus, index manipulation is not possible.

5.3 Property: Operation

This defines how the filter value is processed. You can set different operations (e.g., EQUALS, STARTS_WITH, CONTAINS, etc.) depending on the value of the filter.

If you set a predefined filter value, also set an operation to ensure it is processed the way you want. If you set an operation, it becomes the default operation for your Data Table. As soon as the workspace user adds a new filter, the preselected operation is the one you defined in this property.

5.4 Property: Precision

This defines how precise the filter value is processed. You can set different precisions (e.g., MATCH_CASE, IGNORE_CASE, etc.) depending on the type of filter.

If you set a predefined filter value, also set a precision to make sure it is processed the way you want. If you set a precision, it becomes the default precision for your Data Table. As soon as the workspace user adds a new filter, the preselected precision is the one you defined in this property.

5.5 Filter: Textfield

This filter is used for free text filtering. The user will be able to write a string that will be processed. It is the most basic filter and is also the default filter for all columns.

Note: The “Index” for this filter can be of any type. It will be transformed into a string.

5.6 Filter: Numeric

This filter is used for numbers (e.g., Integer, Float, Double, etc.). It provides special operations like IS_GREATER_THAN, etc.

It is also possible to filter for a range of numbers. To provide a range as the default value, set the property “value” using the following syntax in the Appway Script Language:

// A range greater or equal 4 and lower or equal 5
Range $range := << [ 4,5 ] >>

// A range greater than 4 and lower or equal 5
Range $range := << ] 4,5 ] >>

// A range greater than 4 and lower than 5
Range $range := << ] 4,5 [ >>

Note: The “Index” for this filter has to be of a numeric type (e.g., Integer, Long, Double, Float, etc.).
A string or another type whose string value can be parsed as a number works as well, but the parsing will result in a performance loss.

5.7 Filter: Dropdown

This is used if you have a finite set of possible filter values. For example, if the column shows genres of a movie and the possible genres are predefined, you can provide a dropdown from which the user can select one or more genres. This provides better user experience than a text field since the user would have to know what to filter for.

The following shows a “Dropdown” filter in action.

DropdownFilter-1.png

Use the ConfigSet to specify options. You can set it in the property “Config” of the filter. Each entry in the ConfigSet renders as an option in the dropdown, with the value as the displayed label. Since the ConfigSet is an ordered list, it is guaranteed that the dropdown's options will be rendered in the same order as defined in the ConfigSet.

ConfigSet $config := NEW(ConfigSet);
$config.set('Action', 'Action');
$config.set('Adventure', 'Adventure');
$config.set('Crime', 'Crime');
$config.set('Drama', 'Drama');
$config.set('Fantasy', 'Fantasy');
$config.set('Mystery', 'Mystery');
$config.set('Romance', 'Romance');
$config.set('Thriller', 'Thriller');
$config.set('War', 'War');
Return $config;

As shown above, the two properties “Operation” and “Precision” are not present in the rendered filter dialog. Even though the workspace user cannot change the value for these properties, they are still of great value. With them, you can define how the entries of your dropdown will be processed.

In the example above, not only one genre is displayed per movie. Instead, a comma-separated list of movies is shown in each cell. The dropdown filter still works even if it shows single genres as its options. This is because the “Operation” of the filter is set to “CONTAINS”, which means as soon as the cell contains the defined genre, it will be a match and thus, visible.

DropdownFilter-2.png

Note: The “Index” for this filter can be of any type. It will be transformed into a string.

5.8 Filter: Date Time

This is used for dates. It provides special operations like IS_GREATER_THAN, DURING_THE_LAST, etc.

It is possible to filter for a date range with this filter. To provide a range as the default value, set the property “value” using the following syntax in the Appway Script Language:

// A range greater or equal $date1 and lower or equal $date2
Range $range := << [ $date1,$date2 ] >>

// A range greater than $date1 and lower or equal $date2
Range $range := << ] $date1,$date2] >>

// A range greater than $date1 and lower than $date2
Range $range := << ] $date1,$date2 [ >>

Note: The “Index” for this filter has to be of type “Date”.
A string or another type whose string value can be parsed as a Date works as well, but the parsing results in a performance loss.

5.9 Filter: Boolean

This is used for columns that present Boolean values (e.g., True, False, Yes, No, 1, 0). It provides a simple UI, in which the user can decide to show rows for which the value parses to true or false.

Note: The “Index” for this filter has to be of type “Boolean”.
A string or another type whose string value can be parsed as a “Boolean” works as well, but the parsing results in a performance loss.

5.10 Value Binding

By default, the Data Table binds the values of the properties “Value”, “Operation” and “Precision” to the variables that were used to define them.

This is useful if another screen of the process needs to know what filter settings a Data Table of a previous screen had when the user left it. It can also be used if an AjaxUpdateArea is triggered, that renders something depending on the current filter settings.

The data type for “Operation” and “Precision” is String.

The data type for “Value” depends on the current type of filter:

  • Textfield — String
  • Numeric — Double | Rang of Double
  • Dropdown — Indexed String
  • Date Time — Date | Range of Date
  • Boolean— Boolean

Important: For some filter types, the binding for the property “Value” only works if the variable is of type “Any”. This is because a value of a filter can have different data types even for the same type of filter.

6 Sorters

Each column has its own sorter. There are different types of sorters depending on the column data.

If a column should not be sortable, set the sorter type to none. No clickable header is rendered and the user will not be able to sort the column.

Sorters-1.png

6.1 Property: Direction

This defines a predefined sorting that is set at the time the Data Table will be rendered. This way, you can set what the user sees when the table is rendered for the first time. Of course, the user can change that value later.

6.2 Property: Index

This is the content of the cell that is used for sorting. It is used to decide whether a row is to be placed further up or down in the corresponding table. Providing an index increases the performance when sorting the table.

Whenever the user sorts a certain column, the server iterates over all rows to compare their content. For each row, it checks all columns with an active sorter. If a column has an active sorter, it first checks if an index is defined for that column. If an index is defined, it uses that index to compare two rows. If no index is defined, it first renders the content of the cell. Then it parses the content to a compatible type that the sorter can handle. Finally, it compares the rows with that value.

By setting an index, the Data Table bypasses the rendering and parsing of the content of each cell by directly using the corresponding index to sort. This leads to a massive performance boost.

Example: If you use a “Numeric” sorter and you use a Data Class that has a property of type Integer to be displayed in the cells, set the index to that Integer property. Like this the Data Table does not have to render the Integer as a String; it only parses it into an Integer again for sorting.

While the index boosts performance, it also has a nice side effect: it is possible to manipulate how your sorter works.

Take for example a column that displays dates. There is no date sorter and it is unnecessary. As long as you provide a “Text”, a “Boolean”, or a “Numeric” representation of the cell value, it is possible to sort the column correctly. With the index, define what the content of the cell contains regarding sorting. If a date is rendered, the index should be the timestamp of the date. The timestamp is a “Numeric” representation of a date and unique to every equal date. Using the timestamp to compare dates sorts them in the correct order, regardless of the formatting in the cell. The index could look like this:

$date.getTime()

Note: The index property is not available for Data Tables that use a Data Class as their source, since filtering and sorting will be delegated to the corresponding model. Thus, index manipulation is not possible.

6.3 Property: Rank

This is only relevant if used in combination with "Direction." Since it is possible to define a direction for multiple columns, provide a rank that will specify the order of the sorted columns. The higher the rank, the later it appears in the resulting collection of sorted columns.

This property only has an effect at render time. Once the Data Table is available, the user is able to resort the columns and create another column sort order by using the shift key while clicking the column headers.

6.4 Sorter: Text

This uses alphanumerical comparison on the index/content of the cells.

Note: The “Index” for this sorter can be of any type. It will be transformed into a string.

6.5 Sorter: Numeric

This uses numerical comparison on the index/content of the cells.

Note: The “Index” for this sorter has to be of a numeric type (e.g., Integer, Long, Double, Float, etc.).
A string or another type whose string value can be parsed as a number is working as well, but the parsing will result in a performance loss.

6.6 Sorter: Boolean

This uses Boolean comparison on the index/content of the cells.

Note: The “Index” for this sorter has to be of type “Boolean”.
A string or another type whose string value can be parsed as a “Boolean” works as well, but the parsing will result in a performance loss.

7 Interaction Mode

An interaction mode defines how a user will browse the content of the table. The Data Table supports two interaction modes: Scrolled or Paged.

To use one over the other is mostly a matter of preference. However, if a Data Table is placed into another scrollable area (this could even be the window itself), set it to Paged interaction. This is because nested scrollbars do not work very well and usually confuse the user.

For both interaction modes, you can define the Selection Mode, either as None or Single. If you select Single, the full row is highlighted when a user clicks on it:

A data table with a selected row

7.1 Scrolled

This interaction mode renders a scrollbar that lets the user scroll through the whole content of the table. This does not mean that the table will load and render all rows at once. Instead, it loads rows as the user scrolls down or up the table (lazy loading).

Although rows are loaded only after the user has stopped scrolling, this interaction mode heavily relies on a fast server-side model. If the rows cannot be fetched quickly, the interaction flow will soon feel slow because a user usually is not used to waiting while scrolling.

The Scrolled mode offers two additional properties:

  • Fetch Size – Defines the number of rows that are loaded at a time. You can change the Fetch Size on the Interaction Mode tab. The fetch size that you define does not mean that the Data Table will always load this exact number of rows from the server. Sometimes, it needs to load more rows in order to fill the whole content area, but it ensures that the number of rows to be loaded is a multiplier of the Fetch Size. Therefore, if the Fetch Size is 20, then the Data Table will load at least 20 rows at a time but possibly 20*(n>0) rows.
    The Fetch Size is of great use if you know the number of rows that your table will most likely have. For instance, if you have a table that has exactly 32 rows, it makes sense to set the Fetch Size to 32. This ensures that the table will not load only 30 rows, and then load the last 2 as soon as the user scrolls.
    Important: Setting a very high value for the Fetch Size is counter-productive since loading too many rows at once will slow down the Data Table.
  • Visible Row Count – Defines how many rows are visible if no absolute height is defined for the Data Table.

7.2 Paged

This interaction mode renders a pager in the status bar of the Data Table. Make sure the status bar is not switched off (see the Status Bar property in the Rendering tab). Otherwise, the user will not be able to switch pages.

The Paged mode offers two additional properties:

  • Page Index – Specifies the index of the page that is loaded when the Data Table is rendered.
  • Rows Per Page – Defines how many rows should be rendered per page. The best value for this depends on the screen design and the total amount of rows.

8 Layout

The layout of a Data Table has multiple aspects. It is not sufficient to just set a width and a height to the table in order to make it look good. The size of the table should not be fixed. Instead, it should integrate into the screen layout by letting it expand in size to its parent component or by letting it size itself according to the number of rows.

Also think of the widths of the different columns. It makes a big difference aesthetically if the column widths are well-balanced according to their content. For instance, if you have a table with three columns where one column shows a title, the second shows a description and the third displays one action icon only. The default is all three columns would share the same width. It looks like this:

Layout-1.png

Instead of the default, set appropriate column widths, either fixed or dynamic. See the chapter “Column Width” for more information.

Layout-2.png

Another aspect of the layout is the adaptive capabilities. Tables do not work well on very small screens. On a mobile phone, for instance, a Table should adapt its whole look and feel, and rearrange the columns into a list view. See the sub-chapter on “Adaptive Layout” for more information on how to set this up.

8.1 Table Size

The size of the data table can be configured in multiple ways. Choose the appropriate method depending on the content of the screen. Use the Resize Mode property of the Layout tab on the Data Table component to define what the size of the table will be based on.

  • Styles — The table is resized according to the custom styles that are applied to it. This means that the table will not size itself at all; the screen designer will have to set styles either by using the styles tab or by creating a CSS resource.
  • Content — This is the opposite of Styles. The table is resized according to the properties defined in the Interaction Mode tab. All custom styling will be ignored. If the interaction mode is set to Scrolled, set a Visible Row Count where the table sets its size to this number of rows plus half a row is visible. The additional half row is necessary to indicate to the user that the table can actually be scrolled. Modern browsers no longer show a scrollbar if a touch interface is present. If the size of the table was set to the exact number of rows, the user might not be aware that there is actually more content to scroll to. If the interaction mode is set to Paged, set a Rows Per Page where the table sets its size so that this number of rows is visible.
  • Auto (default) — The table checks if there are any custom styles that influence its size. If there are, it sticks to them, which is equivalent to the Styles mode. If no styles influence the size of the table, it does what is described in the Content mode.
  • Expand — The table will expand to the next parent component that has a CSS property position:absolute or position:relative. Use this if you want to let the table shrink/grow according to a parent component. However, make sure the parent has a CSS property position:absolute or position:relative. Otherwise, the table will grow to the next parent that does so or even to the whole window.

Note: When the interaction mode is set to Paged, setting the resize mode to Content usually makes most sense.

8.2 Column Width

The Data Column provides multiple ways of setting its width. By default, all columns are equally sized and dynamically expanded to the full width of the table. Depending on the content, some columns require a fixed size; some stay dynamic but require a minimum size. Others should be sized relative to other columns according to a specified ratio.

8.2.1 Property: Width

The width can be set as an integer value, which means the column is rendered with a fixed width. The other possibility is to set it as a string using the postfix "%", meaning, it is rendered with a dynamic width.

Columns with a fixed width are rendered with that width, even if there is not enough space for the column. In this case, the Data Table provides horizontal scrollbars to make it possible to see the whole content. The user is able to resize the column until its minimum width.

For the horizontal scrollbar to be displayed, you need to set the Min Width property for all Data Table columns. See also section below.

All columns with a dynamic width share the space that remains after the columns with a fixed width have been rendered. The dynamic value is interpreted as a weight (not as a percentage). For example, if there are two dynamic columns, one with 50% and one with 150%, then the remaining space will be distributed to the two columns in a ratio of 50:150, meaning, 5:15 or 1:3. Regardless of the calculation, the width of a column will never be smaller than its minimum width setting.

It is possible that the remaining space for the dynamic columns is very small or even less than zero pixels. In that case, the dynamic columns are rendered using their minimum widths. This is why it makes sense to always define a minimum width for each column.

For the movie table example, a dynamic width of 40% is defined for the title column, a fixed width of 50px for the year, a dynamic width of 60% for the genre and a fixed width of 50px for the actions column. This renders the table nicely.

ColumnWidth-1.png

8.2.2 Property: Min Width

To set a minimum width for a column, the value has to be an integer. If you set a value for this property, the column will never be smaller than this value, regardless of whether a dynamic or a fixed width has been set. Not even the user can make the column smaller than this value.

For the scrollbar to be displayed, you need to set the Min Width property for all Data Table columns. See also section above.

8.3 Adaptive Layout

Tables do not work well on very small screens. On a mobile phone, for instance, a Table should adapt its whole look and feel and rearrange the columns into a list view. Set the Data Table to be adaptive. Use the “Layout” tab and activate the “Adaptive” checkbox to enable the adaptive mode of the Data Table.

As soon as the checkbox is active, two more properties appear to let you fine-tune the adaptive behavior of the table. Play with these properties to find the appropriate values. The best setting heavily depends on the content of your table.

Layout-4.png

If the table has switched to the narrow (mobile) layout, then the columns will be rendered in a floating mode. This means they will not necessarily be all in one line anymore, but break into two or more lines so that no horizontal scrollbar is necessary.

Layout-5.png

8.3.1 Property: Adaptive Table Threshold

As soon as the width of the whole table is less than the “Adaptive Table Threshold”, it switches to the narrow layout.

8.3.2 Property: Adaptive Column Threshold

In the narrow layout, all cells share the same width, regardless of what has been set up in the Data Column component. The Data Table tries to arrange the cells of a row in such a way that there will always be the same amount of cells per line when occupying the full width of the table. The “Adaptive Column Threshold” defines the minimum width for the cells. This means that you can control the situation when the cells are rearranged into separate lines. The best value for this depends heavily on the type of content that is presented in the table. Play with it.

Layout-6.png

9 Interlines

A data table can show interlines. The user can click on a row, which then opens up to show more details about the row object.
Interlines work the same way as Ajax Update Areas. They are rendered on demand only. All you have to do is to define a screen that will be rendered as interlines of the table.

For the movies example, another screen is created to show more details about a movie including its poster. The detail screen defines an assigned variable of type Movie that represents the movie to be displayed in the interline.

Interlines-1.png

In the screen for the Data Table, define the detail screen as the interlining screen by using the property "Interlining" and selecting the detail screen.

Interlines-2.png

Finally, provide a value for the assigned variable, which is the movie in each row. Use the "Row Object Variable" that is passed to each row.

Interlines-3.png

Each time an interline is shown, the server renders the detail screen with the corresponding movie as the assigned variable and shows it in the table.

Interlines-4.png

10 Color

You can change the color of the Data Table using Color Business Objects of Appway. There are multiple predefined colors to integrate into the design of your solution.

Color Business Object ID Description
aw.DataTable.addFilterElementBackground Background color of elements in the popup dialog when clicking the “Add Filter” button (Colored red in the image below)
Coloring-AddFilterElementBackground.png
aw.DataTable.addFilterElementBackgroundHovered Background color of hovered elements in the popup dialog when clicking on the “Add Filter” button. (Colored red in the image below)
Coloring-AddFilterElementBackgroundHovered.png
aw.DataTable.addFilterElementText Text color of elements in the popup dialog when clicking the “Add Filter” button (Colored red in the image below)
Coloring-AddFilterElementText.png
aw.DataTable.addFilterElementTextHovered Text color of hovered elements in the popup dialog when clicking the “Add Filter” button (Colored red in the image below)
Coloring-AddFilterElementTextHovered.png
aw.DataTable.cellBorder Border color of the content cells (Colored red in the image below)
Coloring-CellBorder.png
aw.DataTable.columnHeaderBorder Border color of the line separating the header from the content (Colored red in the image below)
Coloring-ColumnHeaderBorder.png
aw.DataTable.columnHeaderText Text color of the column header labels (Colored red in the image below)
Coloring-ColumnHeaderText.png
aw.DataTable.dialogBackground Background color of the dialogs used in the Data Table (Colored red in the image below
aw.DataTable.dialogBorder Border color of the dialogs used in the Data Table (Colored red in the image below)
Coloring-DialogBorder.png
aw.DataTable.evenRowBackground Background color of even rows if the Data Table is rendered in zebra style (Colored red in the image below)
Coloring-EvenRowBackground.png
aw.DataTable.filterButtonBackground Background color of the “Add Filter” button (Colored red in the image below)
Coloring-FilterButtonBackground.png
aw.DataTable.filterButtonText Text color of the “Add Filter” button (Colored red in the image below)
Coloring-FilterButtonText.png
aw.DataTable.filterDialogDescriptionText Text color of possible descriptions in a filter dialog (Colored red in the image below)
Coloring-FilterDialogDescriptionText.png
aw.DataTable.filterDialogErrorText Text color of possible error messages in a filter dialog (Colored red in the image below)
Coloring-FilterDialogErrorText.png
aw.DataTable.filterDialogLogicText Text color of possible logic labels in a filter dialog (Colored red in the image below)
Coloring-FilterDialogLogicText.png
aw.DataTable.filterDialogOperationText Text color of the operation in a filter dialog The operation is oftentimes displayed as a dropdown as shown in the image below (contains). In that case, the color might not be adjustable depending on the browser.
Coloring-FilterDialogOperationText.png
aw.DataTable.filterDialogOptionText Text color of possible filter options in a filter dialog (Colored red in the image below)
Coloring-FilterDialogOptionText.png
aw.DataTable.filterDialogPrecisionText Text color of possible precision label in a filter dialog (Colored red in the image below)
Coloring-FilterDialogPrecisionText.png
aw.DataTable.filterDialogPropertyText Text color of column label in a filter dialog (Colored red in the image below)
Coloring-FilterDialogPropertyText.png
aw.DataTable.filterRuleBackground Background color of an applied filter (Colored red in the image below)
Coloring-FilterRuleBackground.png
aw.DataTable.filterRuleText Text color of an applied filter (Colored red in the image below)
Coloring-FilterRuleText.png
aw.DataTable.hoveredRowBackground Background color of the currently hovered row if “Hover Effect” is enabled in the Data Table (Colored red in the image below)
Coloring-HoveredRowBackground.png

11 Related Links

For design suggestions, see the Data Table section of design.appway.com.

© 2026 Appway AG. All Rights Reserved