ExportBulkAction

Hello. I have a modal named Cdr, it has 90 records, I had a Table Widget that shows all those records, I added the ExportBulkAction in order to select or filter records and export them to Excel:
->bulkActions([
ExportBulkAction::make()
->label('Export calls')
->exporter(CdrExporter::class)
->formats([ExportFormat::Xlsx])
->columnMapping(false)
->modifyQueryUsing(function (Builder $query): Builder {
return $query->whereDcontext($this->company->context());
}),
])
->bulkActions([
ExportBulkAction::make()
->label('Export calls')
->exporter(CdrExporter::class)
->formats([ExportFormat::Xlsx])
->columnMapping(false)
->modifyQueryUsing(function (Builder $query): Builder {
return $query->whereDcontext($this->company->context());
}),
])
If I select all of the 90 rows, the export action will only pick 21, If I pick 1 or 2 it may or may not ignore (see exports image). How can I export the selected rows the right way?
No description
Solution:
Filament should use uniqueid then. Not sure what's the issue. But I'd guess it's not the Exporter but the BulkAction that cannot identify the records correctly
Jump to solution
14 Replies
Dennis Koch
Dennis Koch2mo ago
Are the rows missing because you modify the query?!
->modifyQueryUsing(function (Builder $query): Builder {
return $query->whereDcontext($this->company->context());
})
->modifyQueryUsing(function (Builder $query): Builder {
return $query->whereDcontext($this->company->context());
})
nuovo2023
nuovo2023OP2mo ago
I tried without it, it's the same result. I just added the following to the panel provider:
->databaseNotifications()
->databaseNotificationsPolling('10s')
->databaseNotifications()
->databaseNotificationsPolling('10s')
No description
Dennis Koch
Dennis Koch2mo ago
Does that model have a custom key insteaf of "id"? Can you share the exporter code?
nuovo2023
nuovo2023OP2mo ago
Yes, it doesn't have an id
No description
Dennis Koch
Dennis Koch2mo ago
How do you identify records then?
nuovo2023
nuovo2023OP2mo ago
It's like an event log table, the closest thing to an ID is uniqueid:
protected $table = 'cdr';
public $timestamps = false;
public $incrementing = false;
protected $primaryKey = 'uniqueid';
protected $keyType = 'string';


protected $fillable = [
'accountcode',
'src',
'dst',
'dcontext',
'clid',
'channel',
'dstchannel',
'lastapp',
'lastdata',
'start',
'answer',
'end',
'duration',
'billsec',
'disposition',
'amaflags',
'userfield',
'uniqueid',
'linkedid',
'peeraccount',
'sequence',
];
protected $table = 'cdr';
public $timestamps = false;
public $incrementing = false;
protected $primaryKey = 'uniqueid';
protected $keyType = 'string';


protected $fillable = [
'accountcode',
'src',
'dst',
'dcontext',
'clid',
'channel',
'dstchannel',
'lastapp',
'lastdata',
'start',
'answer',
'end',
'duration',
'billsec',
'disposition',
'amaflags',
'userfield',
'uniqueid',
'linkedid',
'peeraccount',
'sequence',
];
Solution
Dennis Koch
Dennis Koch2mo ago
Filament should use uniqueid then. Not sure what's the issue. But I'd guess it's not the Exporter but the BulkAction that cannot identify the records correctly
nuovo2023
nuovo2023OP2mo ago
No, it was me, I forgot to set keyType
Dennis Koch
Dennis Koch2mo ago
So it's working now?
nuovo2023
nuovo2023OP2mo ago
Yes, one last question, when exporting is done it triggers a silent notification, how can I make it pop out?
Dennis Koch
Dennis Koch2mo ago
I don't think you can. It's a database notification. They don't popup
nuovo2023
nuovo2023OP2mo ago
Can I trigger a download by using ->after()
Dennis Koch
Dennis Koch2mo ago
After on the Action? That runs after the action, not after the export The export runs on the queue.
nuovo2023
nuovo2023OP2mo ago
Oh, It makes sense. Thanks for the help
Want results from more Discord servers?
Add your server