Data Table Layout
A snapshot of how a user has arranged a table: column widths, which columns they hid, the order they put them in, the sort they left it under, and the filters they typed.
Everything a user changes about a grid is here, and nothing about the data is — a layout is keyed entirely by DataTableHeader.key, so it survives the rows being replaced, and can be saved against a user rather than against a query.
Capture one with DataTableState.captureLayout and put it back with DataTableState.applyLayout. To store it between sessions, either use encodeToString, or map these fields onto your own serializable type — they are all plain data, and Dp is a Float in dp behind Dp.value.
A layout is applied by key, so one saved before a column was added, removed, or renamed still applies: entries naming columns that no longer exist are ignored, and columns the layout has never heard of keep their declared width and sit after the ones it names.
Constructors
Types
Reads back what encodeToString wrote.
Properties
Column keys in the order the user put them. Columns missing from the list follow the ones in it, in declaration order — which is where a column added since the layout was saved appears.
Widths the user dragged columns to. A column absent from the map keeps the width its header declares.
Columns the user hid. This adds to DataTableHeader.visible = false rather than overriding it: a column a caller declared unavailable stays unavailable however the layout was saved.
The multi-column sort in force, which takes precedence over sortBy.