WEBVTT

1
00:00:00.608 --> 00:00:08.896
In lesson one the rows were made up. In this one they are yours, they stay reactive, and the columns start looking like a real application.

2
00:00:10.745 --> 00:00:23.166
Start from your own row type. The grid never asks you to convert anything: whatever shape your records have, that is the shape it takes. Declare the array with the state rune and it stays reactive.

3
00:00:23.491 --> 00:00:32.615
Columns map a field to a header, and width fixes one that would otherwise stretch. Then a plain function that pushes a record onto the array.

4
00:00:32.937 --> 00:00:43.083
Watch what happens when that button runs. Pushing onto the array is all it does, and the grid follows, because the rows are a rune and not a copy the grid took at startup.

5
00:00:43.495 --> 00:00:52.062
Now formatting. This is the same page of the docs, a few blocks further down, and it is the thing people most often do by hand and regret.

6
00:00:52.387 --> 00:01:05.551
A currency format, a percent, a date. Each one renders the value for the reader and leaves your data alone, which matters because sorting and exporting both use the raw number underneath, not the string on screen.

7
00:01:05.964 --> 00:01:18.292
One habit worth forming: type the column array as GridColumns of your row type. The compiler then checks every field name against the row, so a typo is a build error instead of an empty column nobody notices.

8
00:01:20.243 --> 00:01:25.652
Both files are on the page below, and they run there too. See you in lesson three.
