Skip to content

V9 / Svelte 5: How to make Row Selection Work? #5857

Closed Answered by selcuk-sahin
selcuk-sahin asked this question in Q&A
Discussion options

You must be logged in to vote

I was finally able to solve by looking at the example in column-visibility, Many Thanks for that!

what I was missing was the setting rowSelection as $state, and then passing it via getter!

  let rowSelection = $state<RowSelectionState>({})

  function onRowSelectionChange(updater: Updater<RowSelectionState>) {
    if (updater instanceof Function) {
      rowSelection = updater(rowSelection as RowSelectionState)
    } else {
      rowSelection = updater
    }
  }

  const table = createTable({
    state: {
      get rowSelection() {
        return rowSelection
      },
    },
    enableRowSelection: true,
    onRowSelectionChange,
    // ... other props
  })

For the checkbox-component, it …

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by selcuk-sahin
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
1 participant