Table Rendering
Text | Index |
---|---|
0 | Kaiware 5282 |
1 | Tako 1277 |
2 | Tobiwo 4182 |
3 | Ebi 2797 |
4 | Kani 8747 |
5 | Suzuki 6991 |
<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