Power-Components / livewire-powergrid

⚡ PowerGrid generates modern, powerful and easy-to-customize data tables using Laravel Livewire.
https://livewire-powergrid.com
MIT License
1.42k stars 209 forks source link

[FEATURE] Add noDataLabel to customize "no records found" message #1458

Closed dansysanalyst closed 3 months ago

dansysanalyst commented 4 months ago

⚡ PowerGrid - Pull Request

Welcome and thank you for your interest in contributing to our project!. You must use this template to submit a Pull Request, or it will not be accepted.


Motivation

Description

This Pull Request adds the possibility to customize the no-data message ("No records found") individually in each component.

Individualized messages can be useful when having multiple PowerGrid components on the same page, and they also to provide more contextualized messages to users.

Usage:

The user may override the method noDataLabel() returning his own message.

use Illuminate\View\View;

class DishTable extends PowerGridComponent
{
    //...

    public function noDataLabel(): string|View
    {
        return 'We could not find any dish matching your search.';
    }
}

For the user's convenience, the method may also return a View.

use Illuminate\View\View;

class DishTable extends PowerGridComponent
{
    //...
    public function noDataLabel(): string|View
    {
        return view('dishes.no-data');
    }
}

I will provide a PR in PowerGrid's documentation once the implementation is approved.

Related Issue(s): #_____.

Documentation

This PR requires Documentation update?