Controlled object-table
Last updated
Last updated
A controlled object-table
(<
="false">
) contains data that is controlled by external code only. It will therefore not handle the pagination, sorting or filtering of data. Instead, you are required to communicate to the component:
the amount of pages,
what data should display for the current page,
and what should happen when the state changes.
object-table
The table represents remote API data
When working with Big data
Running into performance issues
The Showcase: Object Tables template app contains an example implementation of a controlled object-table
. Check it out!
Implementing a controlled object-table
requires the use of , ="paginate"
, ="false"
and the attributes on the object-table
.
When a table receives an automatic="false"
attribute it will automatically go into controlled mode. The page-count
attribute must contain a function which returns the total number of pages, since the component cannot determine the page count in its own.
An on-state-change
attribute also needs to be added to record the next state of the object-table
for when a page button is selected or filtering gets applied. When this function fires, you should mutate the query passed to the table to represent the new state by means of limiting, sorting and skipping the underlying query.
Here is the full list of steps:
Create a variable to store the initial state and the computed pages
Use this variable to setup the initial query
Setup a function for when the state changes
Set the object-table
up similar to this example: