How to get selected record from table in header action?
I want to make header action that can collect the selected record link in bulkaction and send all value to custom view in new tab, i have search in doc but i still not find any clue, this is my code
->headerActions([
Action::make('Label')
->url(fn () => route('label', ['selected_records' => ['33', '34']]))
->openUrlInNewTab(),
])
i want selected_records is array from selected record like bulkaction,
Thank you
Solution:Jump to solution
I have found a simple solution for this problem, I use notification for opening bulk action in new tab, this is my code
```BulkAction::make('Label Barcode')
->label('Label Barcode')
->action(function ($records) {...
4 Replies
Just curious: why not use a BulkAction?
I already use bulkaction, but i can not find how to open it in new tab, i just success to open it in same tab, this is my code now
in resource
'''
BulkAction::make('Label Barcode')
->label('Label Barcode')
->action(function ($records) {
$selectedRecordIds = $records->pluck('id')->toArray();
$route = route('label', ['selected_records' => $selectedRecordIds]);
return redirect($route);
})
->deselectRecordsAfterCompletion(),
'''
in model
'''
public function labelBarcode(Request $request)
{
$selectedRecordIds = $request->input('selected_records', []);
$selectedRecords = AsetGuna::with('NamaAset')->with('lokasi')
->whereIn('id', $selectedRecordIds)->get();
return view('filament.label')->with('selectedRecords', $selectedRecords);
}
'''
in route
'''
Route::get('label', [AsetGuna::class, 'labelbarcode'])->name('label');
'''
have you any experience to open bulkaction in new tab?
I don't think you can redirect in a new tab unfortunately
Maybe you can emit a Livewire event and add some JS code to open the new tab?
Solution
I have found a simple solution for this problem, I use notification for opening bulk action in new tab, this is my code