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. Layout

Usage

To use the Layout class, you need to include it in the getLayout method of your grid class. Here is an example:

use BoredProgrammers\LaraGrid\Components\Layout;

class MyGrid extends BaseLaraGrid
{
    protected function getLayout(BaseLaraGridTheme $theme): array
    {
        return Layout::make()
            ->setHeaderRenderer(function () {
                return view('my-grid.header');
            })
            ->setFooterRenderer(function () {
                return "This is the footer";
            })
            ->setFooterRenderer(function () {
                return "<b>This is the footer</b>";
            })
    }
}

In the example above, we have used the setHeaderRenderer method to set the header of the grid. The setHeaderRenderer method takes a closure as an argument. The closure can return a view, string, or any other valid HTML.

The setFooterRenderer method works the same way as the setHeaderRenderer method.

PreviousDescriptionNextWhy do we use it

Last updated 1 year ago

Was this helpful?