LaraGrid
  • LaraGrid
  • Installation
  • Publishable
  • Usage
    • Base Usage
      • Create a Grid
      • Display a Grid
    • Examples
  • Theme
    • Default Theme
    • Customize the Theme
  • Column
    • Description
    • Create a Column
    • Methods
    • Usage
  • Column Group
    • Description
    • Create a ColumnGroup
    • Methods
    • Usage
  • Filter
    • Description
    • Available Filters
    • Usage
    • Custom Builder
    • Custom filter
    • Show filtering and sorting in url
  • Filter Reset Button
    • Description
    • Usage
    • Customization
  • Layout
    • Description
    • Usage
  • PowerJoins in LaraGrid
    • Why do we use it
Powered by GitBook
On this page

Was this helpful?

  1. Filter

Show filtering and sorting in url

If you want to show filtering and sorting in url, you need to rewrite default LaraGrid properties. You can do it like this:

abstract class MyBaseGrid extends BaseLaraGrid
{

    #[Url]  // we added this line
    public array $filter = [];

    #[Url(except: 'id')] // we added this line
    public string $sortColumn = 'id';

    #[Url]  // we added this line
    public string $sortDirection = 'desc';

    protected function getFilterResetButton(): FilterResetButton
    {
        return FilterResetButton::make();
    }

    protected function getTheme(): BaseLaraGridTheme
    {
        return MyTheme::make();
    }

}
PreviousCustom filterNextDescription

Last updated 1 year ago

Was this helpful?

Those Url params are default from livewire, so you can customize them as you want by following .

livewire docs