Table Rendering
Text | Index |
---|---|
0 | Natto 7152 |
1 | Maki 0328 |
2 | Otoro 2894 |
3 | Nigiri 7760 |
4 | Ana-kyu 3948 |
5 | Tako 2117 |
<script lang="ts">
import { VirtualList } from 'svelte-virtuallists';
import { getRandomSushi } from '../sushi';
const myModel = new Array(10000).fill(1).map(() => {
return { text: getRandomSushi() };
});
</script>
<VirtualList items={myModel} class="list-table" style="height:600px" isTable={true}>
{#snippet header()}
<thead>
<tr>
<th>Text</th>
<th>Index</th>
</tr>
</thead>
{/snippet}
{#snippet vl_slot({ item, index })}
<tr>
<td>{index}</td>
<td>{item.text}</td>
</tr>
{/snippet}
</VirtualList>
<style global>
.list-table table,
.list-table td,
.list-table th {
border: 1px solid #ccc;
}
.list-table table {
border-collapse: collapse;
width: 100%;
}
</style>
previous Horizontal
next Variable Sizing