Enable row selection
To enable row selection, rows must have at least a unique id field.
This unique id must be defined in TableHandler
params:
const table = new TableHandler(data, { selectBy: 'id' })
Select a row
- Is row selected ?
table.selected.includes(id)
- Select a row:
table.select(id)
{#each table.rows as row}
<tr class:active={table.selected.includes(row.id)}>
<td>
<input type="checkbox"
checked={table.selected.includes(row.id)}
onclick={() => table.select(row.id)}
>
</td>
</tr>
{/each}
id | first_name | last_name | |
---|---|---|---|
1 | Tobie | Vint | |
2 | Zacharias | Cerman | |
3 | Gérianna | Bunn | |
4 | Bee | Saurin | |
5 | Méyère | Granulette | |
6 | Frederich | Benley | |
7 | Becki | Criag | |
8 | Nichols | Risom | |
9 | Ron | Menendes | |
10 | Thane | Gammill |