I'm currently available for full time hire! Inquire Here

Laravel Livewire Tables Documentation

🎉 Enjoying this package? Consider sponsoring me on GitHub or buying me a beer.

This is the documentation for v3. You can switch versions in the menu at the top. Check your current version with the following command:

composer show rappasoft/laravel-livewire-tables

Available Methods

These are the available configuration methods for bulk actions.


setBulkActions

Set the bulk actions array.

1public function configure(): void
2{
3 $this->setBulkActions([
4 'exportSelected' => 'Export',
5 ]);
6}

setBulkActionsStatus

Enabled by default, enable/disable bulk actions for the component.

1public function configure(): void
2{
3 $this->setBulkActionsStatus(true);
4 $this->setBulkActionsStatus(false);
5}

setBulkActionsEnabled

Enable bulk actions on the component.

1public function configure(): void
2{
3 // Shorthand for $this->setBulkActionsStatus(true)
4 $this->setBulkActionsEnabled();
5}

setBulkActionsDisabled

Disable bulk actions on the component.

1public function configure(): void
2{
3 // Shorthand for $this->setBulkActionsStatus(false)
4 $this->setBulkActionsDisabled();
5}

setSelectAllStatus

Disabled by default, enable/disable pre-selection of all bulk action check boxes.

1public function configure(): void
2{
3 $this->setSelectAllStatus(true);
4 $this->setSelectAllStatus(false);
5}

setSelectAllEnabled

Check all bulk action checkboxes.

1public function configure(): void
2{
3 // Shorthand for $this->setSelectAllStatus(true)
4 $this->setSelectAllEnabled();
5}

setSelectAllDisabled

Deselect the select-all bulk actions checkbox.

1public function configure(): void
2{
3 // Shorthand for $this->setSelectAllStatus(false)
4 $this->setSelectAllDisabled();
5}

setHideBulkActionsWhenEmptyStatus

Disabled by default, enable/disable hiding of bulk actions dropdown when empty.

1public function configure(): void
2{
3 $this->setHideBulkActionsWhenEmptyStatus(true);
4 $this->setHideBulkActionsWhenEmptyStatus(false);
5}

setHideBulkActionsWhenEmptyEnabled

Hide bulk actions dropdown when empty.

1public function configure(): void
2{
3 // Shorthand for $this->setHideBulkActionsWhenEmptyStatus(true)
4 $this->setHideBulkActionsWhenEmptyEnabled();
5}

setHideBulkActionsWhenEmptyDisabled

Show bulk actions dropdown when empty.

1public function configure(): void
2{
3 // Shorthand for $this->setHideBulkActionsWhenEmptyStatus(false)
4 $this->setHideBulkActionsWhenEmptyDisabled();
5}

setBulkActionConfirms

When a bulk action is included in the array passed to setBulkActionConfirms, the default wire:confirm pop-up will appear prior to executing the bulk action. The default message is: "Are you sure?". This should only be used if you wish to use the default message.

1public function configure(): void
2{
3 $this->setBulkActionConfirms([
4 'delete',
5 'reset'
6 ]);
7}

setBulkActionDefaultConfirmationMessage

You may use this method to over-ride the default message. To override the confirmation message for an individual Bulk Action, see the below setBulkActionConfirmMessage and setBulkActionConfirmMessages. You may also use the language files to do this.

1public function configure(): void
2{
3 $this->setBulkActionDefaultConfirmationMessage('Are you certain?');
4}

setBulkActionConfirmMessage

You may use this method to specify a message other than the default message.

1public function configure(): void
2{
3 $this->setBulkActionConfirmMessage('delete', 'Do you want to delete these items?');
4}

setBulkActionConfirmMessages

You may pass an array to this method, to more effectively update the confirmation message for a larger quantity of bulk actions. This expects an array keyed by the bulk action name, with the value being the message that will be displayed to the user.

1public function configure(): void
2{
3 $this->setBulkActionConfirmMessages([
4 'delete' => 'Are you sure you want to delete these items?',
5 'purge' => 'Are you sure you want to purge these items?',
6 'reassign' => 'This will reassign selected items, are you sure?',
7 ]);
8}

setShouldAlwaysHideBulkActionsDropdownOption

Allows hiding the Bulk Actions button & menu, regardless of whether there are any items selected, or hideBulkActionsWhenEmptyEnabled behaviour

1public function configure(): void
2{
3 $this->setShouldAlwaysHideBulkActionsDropdownOption(true);
4}

setShouldAlwaysHideBulkActionsDropdownOptionEnabled

Allows hiding the Bulk Actions button & menu, regardless of whether there are any items selected, or hideBulkActionsWhenEmptyEnabled behaviour

1public function configure(): void
2{
3 $this->setShouldAlwaysHideBulkActionsDropdownOptionEnabled();
4}

setShouldAlwaysHideBulkActionsDropdownOptionDisabled

Restores the Bulk Actions to default functionality, so it will respect the hideBulkActionsWhenEmptyEnabled behaviour

1public function configure(): void
2{
3 $this->setShouldAlwaysHideBulkActionsDropdownOptionDisabled();
4}

setClearSelectedOnSearch

By default, any selected items for Bulk Actions are cleared upon searching. You may configure this behaviour here.

1public function configure(): void
2{
3 $this->setClearSelectedOnSearch(true);
4}

setClearSelectedOnSearchEnabled

By default, any selected items for Bulk Actions are cleared upon searching. This enables this behaviour.

1public function configure(): void
2{
3 $this->setClearSelectedOnSearchEnabled();
4}

setClearSelectedOnSearchDisabled

By default, any selected items for Bulk Actions are cleared upon searching. This disables this behaviour, ensuring that selected items are retained after searching.

1public function configure(): void
2{
3 $this->setClearSelectedOnSearchDisabled();
4}

setClearSelectedOnFilter

By default, any selected items for Bulk Actions are cleared upon filtering. You may configure this behaviour here.

1public function configure(): void
2{
3 $this->setClearSelectedOnFilter(true);
4}

setClearSelectedOnFilterEnabled

By default, any selected items for Bulk Actions are cleared upon filtering. This enables this behaviour.

1public function configure(): void
2{
3 $this->setClearSelectedOnFilterEnabled();
4}

setClearSelectedOnFilterDisabled

By default, any selected items for Bulk Actions are cleared upon filtering. This disables this behaviour, ensuring that selected items are retained after filtering.

1public function configure(): void
2{
3 $this->setClearSelectedOnFilterDisabled();
4}

setDelaySelectAllEnabled

By default, using the "Select All", immediately makes a call to the backend to populate the "selected" array with the primary key of all resultant rows (based on Filter/Search). This can be slow with large result sets, but gives a good user experience with smaller results, as it allows them to "Select All" and then deselect some rows.

1public function configure(): void
2{
3 $this->setDelaySelectAllEnabled();
4}

This prevents the default behaviour from firing, which improves performance when working with very large sets of data. With this feature enabled, the backend update will not fire, however an indication that all result rows have been selected will be passed to the backend, and the frontend will behave as if all rows are selected.

When running your Bulk Action, having used "Select All", you may then access the array of "all rows" based on your most recent search/filter results:

1$rows = $this->getSelectedRows();

Once your bulk action completes, ensure that you call:

1$this->clearSelected();

IMPORTANT NOTES

Actions After Frontend Select All

If you apply a filter/search/sort, then the delay select will be abandoned, and the array will be populated. Ensure that you do not do this!

Use of setSelectAll

Do NOT call either of these methods, as they will prevent the correct method from working. These two methods SELECT ALL regardless of what the frontend is doing.

1$this->setSelectAllStatus(true);
2$this->setSelectAllEnabled();

setDelaySelectAllDisabled

This is the default behaviour, see setDelaySelectEnabled for details on what enabling this does.