#Accessing the selected records before firing a bulk action

6 messages · Page 1 of 1 (latest)

fast sonnet
#

Hello, is it possible to access the selected records somehow before firing a bulk action, maybe using javascript or if there is a function that let's me access them as soon as i select them?

hollow ventureBOT
#

To help others find answers, you can mark your question as solved via Right click solution message -> Apps -> ✅ Mark Solution

lyric ore
#

Hi, you could do this for example with a custom BulkAction:

BulkAction::make('bulkEdit')
    ->name('My action')
    ->icon('heroicon-o-pencil')
    ->form([
        Select::make('a_select_field')
    ])
    ->action(function (Collection $records, array $data) {
        $data = array_filter($data);
        return $records->each->update($data);
    })
    ->deselectRecordsAfterCompletion(),

You also have the before() method:

Tables\Actions\DeleteBulkAction::make()
    ->before(function (Collection $records) {
        // ...
    })
fast sonnet
#

actually i want to access the selected records before i click the action, before is not working until i click the the bulk action

lyric ore
#

oh gotcha

sour schooner
#

Is this possible, to access the selected records before clicking the bulk action?