How to Use Table
Displaying Data in a Table
- Click [Create] next to [Dataflows].
- Select [Onboarding DB] in [Select resource].
- Change the name of the dataflow next to the [Run] button to
listUsers
. - Write the following query in [SQL]:
SELECT * FROM users LIMIT 20;
- Press [Run] to run.
- Place a [Table] element.
- Enter
{{ listUsers.data }}
in [Data] of the [Table].
Note: If values retrieved from a REST API or other sources are nested, you can access nested data by writing something like {{ listUsers.data.users }}
.
Modifying the Display of Columns in the Table
Set the display name of the columns in [Display name].
Select the type of data display in [Type].
You can hide columns by turning on [Hidden].
You can also change the order of columns by dragging and dropping each column in the column list.
Changing the Height of the Table
Select the table and edit the [Height] field to change the height of the table.
If you want to dynamically change the height based on the retrieved data, you can set a dynamic height by entering {{ dataflow1.data.length }}
.
Note: The maximum height is 20.
Setting Pagination
You can set pagination from the table component. Currently, it supports Limit-Offset based and Cursor based pagination.
Setting Limit-Offset Based Pagination
Displaying User Information in the Table
- Click [Create] on the right side of [Dataflows].
- Change the dataflow name next to the [Run] button to
listUsers
. - Select [Onboarding DB] in [Select resource] and check [Run automatically on inputs change].
- Enter the following SQL in [SQL]:
```sql SELECT * FROM users LIMIT 10 OFFSET 0; ```
- Click [Run] to run.
- Drag & drop a [Table] onto the canvas and enter
{{ listUsers.data }}
in [Data].
Reflecting Total Data Count in the Table
- Click [Create] on the right side of [Dataflows].
- Change the dataflow name next to the [Run] button to
countUsers
. - Select [Onboarding DB] in [Select resource].
- Enter the following SQL in [SQL]:
SELECT COUNT(*) as count FROM users;
- Click the placed [Table] and check [Pagination > Server-side pagination] in [Inspect].
- Select
Offset-based
in [Type]. - Write
{{ countUsers.data[0].count }}
in [Total count].
Setting Limit/Offset in dataflow
- Click
listUsers
from the dataflow list and modify the SQL as follows:
SELECT * FROM users
LIMIT 10
OFFSET {{ table1.paginationOffset }};
- Verify the pagination functionality.
Setting Cursor Based Pagination
Displaying User Information in the Table
- Click [Create] on the right side of [Dataflows].
- Change the dataflow name next to the [Run] button to
listUsers
. - Select [Onboarding Firebase] in [Select resource] and check [Run automatically on inputs change].
- Select
List documents
in [Action]. - Enter
users
in [Collection] and10
in [Limit]. - Enter
id
in [Order by]. - Press [Execute] to run.
- Drag & drop a [Table] onto the canvas and enter
{{ listUsers.data }}
in [Data].
Preparing the Table Component for Cursor Based Pagination
- Click the placed [Table] and check [Pagination > Server-side pagination] in [Inspect].
- Select
Cursor-based
in [Type]. - Enter the following in [Next Page Cursor]:
{{ dataflow1.data[dataflow1.data.length - 1].id }}
- Enter the following in [Previous Page Cursor]:
{{ dataflow1.data[0].id }}
- Enter the following in [Has More]:
{{ dataflow1.data.length >= 10 }}
Setting Cursors in dataflow
- Click
listUsers
from the dataflow list and enter{{ table1.nextPageCursorValue }}
in [Start after] and{{ table1.previousPageCursorValue }}
in [End at]. - Verify the pagination functionality.