Skip to content

svelte checkbox Row Selection all example? #4770

Answered by ollydowning
exqmjmz asked this question in Q&A
Discussion options

You must be logged in to vote

Hi @LJM000,

I was struggling with this myself, and have come up with the following solution.

First, create a RowCheckBox.svelte component:

<script lang="ts">
    export let checked, indeterminate, onChange;
</script>

<input class="checkbox" type="checkbox" on:change={onChange} {checked} bind:indeterminate={indeterminate}/>

Next, define your column's as normal, passing in the following items we'll need in the component.

const defaultColumns: ColumnDef<Child>[] = [
    {
        id: 'select',
        header: ({table}) => renderComponent(RowCheckBox, {
            checked: table.getIsAllRowsSelected(),
            indeterminate: table.getIsSomeRowsSelected(),
            onChange: table.get…

Replies: 2 comments

Comment options

You must be logged in to vote
0 replies
Answer selected by exqmjmz
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants