Introducing Laravel Quizzes! Play now

What's New in Livewire Tables v2.1-2.4

What's New in Livewire Tables v2.1-2.4


In just a short month after the successful release of version 2 of Livewire Tables, there have been 4 minor releases with a few cool additions to note:

v2.1

Added missing table row click functionality

This was a missing feature from version 1 that allowed you to click a row and navigate to a URL.

This is actually implemented as cell clicks that all together make the entire row clickable. I did it this way so that we could exclude certain cells from the click functionality in case there is another clickable item inside that cell.

From the docs:

public function configure(): void
{
    $this->setPrimaryKey('id')
        ->setTableRowUrl(function($row) {
            return route('admin.users.show', $row);
        })
        ->setTableRowUrlTarget(function($row) {
            if ($row->isExternal()) {
                return '_blank';
            }

            return '_self';
        });
}

Added ability to mark column as unclickable if you need a cell to have another clickable element with clickable rows turned on.

As stated above, you can exclude certain cells from the click functionality:

Column::make('Name')
    ->unclickable(),

v2.2

Add custom markup at the end of the component

You can now implement this method on the component and it will load your view right before the ending component tag. Good for loading modals.

From the docs:

public function customView(): string
{
    return 'includes.custom';
}

Disable columns from column select by default

Previously, there was no way to have a column hidden from column select by default. You can now specify:

Column::make('Address', 'address.address')
    ->deselected(),

Number Filter

A new filter based on the HTML number input.

public function filters(): array
{
    return [
        NumberFilter::make('Amount')
            ->config([
                'min' => 0,
                'max' => 100,
            ])
            ->filter(function(Builder $builder, string $value) {
                $builder->where('amount', '<', $value);
            }),
    ];
}

v2.3

Ability to define additional select statements outside of columns

Sometimes you need to select columns that you don't have physical columns for. For example you probably don't want an ID column but you may need the ID selected to have action buttons or whatnot.

So you can now specify additional selects on the configuration:

public function configure(): void
{
  $this->setAdditionalSelects(['users.id as id']);
}

Added 8 configurable areas

You can now specify configurable areas around the table to add your own components to the toolbar and such.

Read the docs for full details

v2.4

Added 4 table event listeners to hook into

You can now fire events from other components on the page to sort and filter the datatable:

From the docs:

$this->emit('setSort', 'name', 'asc');

Text Filters

A new filter based on the HTML text field:

public function filters(): array
{
    return [
        TextFilter::make('Search Name')
            ->config([
                'placeholder' => 'Search Name',
                'maxlength' => '25',
            ])
            ->filter(function(Builder $builder, string $value) {
                $builder->where('users.name', 'like', '%'.$value.'%');
            }),
    ];
}

setThSortButtonAttributes() to set attributes for th sort button

Previously, these classes were locked and uneditable. You can now configure them:

public function configure(): void
{
  // Takes a callback that gives you the current column.
  $this->setThSortButtonAttributes(function(Column $column) {
    if ($column->isField('name')) {
      return [
        'class' => 'bg-green-500',
      ];
    }

    return [];
  });
}

setHideConfigurableAreasWhenReorderingStatus() to hide configurable areas when reordering status which now defaults to true

Configurable areas are now hidden by default when reordering, but you can set the status yourself:

public function configure(): void
{
  $this->setHideConfigurableAreasWhenReorderingStatus(true);
  $this->setHideConfigurableAreasWhenReorderingStatus(false);
}

Fix issue with passing parameters to builder() and columns()

Parameters passed into the component are now correctly available in the builder() and columns() methods.

Other minor changes

  • Reworked query builder to fix mount parameter problems with lifecycle event order.
  • Fixed possible bug with bulk actions dropdown on Tailwind when bulk actions are hidden until a selection is made.
  • Fixed filter dropdown opening on sort
  • Fixed issue with Postgres and quotes
  • Update filter docs
  • Update getTdAttributes to take 4th missing argument
  • Add filters in the config section
  • Update some docs formatting
  • Turkish translation
  • Events documentation
  • Added $row as second parameter to BooleanColumn setCallback().
Anthony Rappa

By Anthony Rappa

Hello! I'm a full stack developer from Long Island, New York. Working mainly with Laravel, Tailwind, Livewire, and Alpine.js (TALL Stack). I share everything I know about these tools and more, as well as any useful resources I find from the community. You can find me on GitHub and LinkedIn.