Skip to content

Preselect Table records on page load #14392

Answered by BradnDodd
BradnDodd asked this question in Help
Discussion options

You must be logged in to vote

After a lot of trail and error I have finally got a working solution for this that I can share;

  1. In your livewire component that has HasTable add the following method which will dispatch the event to handle the front end
public function rendered()
    {
        $this->dispatch('trigger-select-records', [
            'records' => [1], // The IDs of your selected rows
            'livewireId' => $this->id(), // Required to link to this specific component incase you need to have multiple of the same component or multiple components supporting preselected rows
        ]);
    }
  1. In your blade template for your component add the following which will select your rows in the backend by trigger…

Replies: 1 comment 5 replies

Comment options

You must be logged in to vote
5 replies
@elmudometal
Comment options

@BradnDodd
Comment options

@elmudometal
Comment options

@BradnDodd
Comment options

@elmudometal
Comment options

Answer selected by BradnDodd
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Help
Labels
None yet
2 participants