Skip to content

Empty Data State โ€‹

Introduction โ€‹

When a table returns no rows, PowerGrid shows a message. The default is the translation livewire-powergrid::datatable.labels.no_data ("No records found"). Override renderEmptyState() to return a string or a View.

Customizing the empty state โ€‹

String:

phpapp/Livewire/ProductTable.php
use PowerComponents\LivewirePowerGrid\PowerGridComponent;
use Illuminate\View\View;

class ProductTable extends PowerGridComponent
{
    public function renderEmptyState(): string|View
    {
        return 'No items found. Create your first product.';
    }
}

View:

phpapp/Livewire/ProductTable.php
use PowerComponents\LivewirePowerGrid\PowerGridComponent;
use Illuminate\View\View; 

class ProductTable extends PowerGridComponent
{
    public function renderEmptyState(): string|View
    {
        return view('products.empty-data');
    }
}

When the return value is a View, PowerGrid passes emptyState (the default translated string) and data (an empty array) into it.

noDataLabel() still exists and is the default implementation of renderEmptyState(). It is deprecated; override renderEmptyState() instead.

Created By Luan Freitas and @DanSysAnalyst