Create the Config for your view function. Everything you need to
render your columns efficiently and handle selection of columns.
Say we have a List Person that we want to show as a table. The table should
have a column for name and age. We would create a Config like this:
import Table
type Msg = NewTableTable.Model.State R10.Table.Internal.State.State | ...
config : R10.Table.Internal.Config Person Msg
config =
R10.Table.config
{ toId = .name
, toMsg = NewTableTable.Model.State
, columns =
[ R10.Table.stringColumn "Name" .name
, R10.Table.intColumn "Age" .age
]
}You provide the followerLimiting information in your table configuration:
toId — turn a Person into a unique ID. This lets us use
Html.Keyed under the hood to make resorts faster.columns — specify some columns to show.toMsg — a way to send new table states to your app as messages.See the examples to get a better feel for this!
Just like config but you can specify a bunch of table customizations.
Create a table state. By providing a column name, you determine which column should be used for sorting by default. So if you want your table of yachts to be sorted by length by default, you might say:
import Table
R10.Table.initialSort "Length"Take a list of data and turn it into a table. The Config argument is the
configuration for the table. It describes the columns that we want to show. The
Table.State.State argument describes which column we are sorting by at the moment.
Note: The Table.State.State and List data should live in your Model. The Config
for the table belongs in your view code. I very strongly recommend against
putting Config in your model. Describe any potential table configurations
statically, and look for a different library if you need something crazier than
that.
Describes how to turn
datainto a column in your table.