Usage

The ColumnGroup class is used in the getColumns method of your Livewire component to define the column groups that will be displayed in the grid.

protected function getColumns(): array
{
    return [
        ColumnGroup::make('User Details')
            ->setColumns([
                Column::make('first_name'),
                Column::make('last_name'),
            ]),
        ColumnGroup::make('Actions')
            ->setColumns([
                ActionButton::make('View')->setRenderer(function ($record) {
                    return '<a href="' . route('detail', $record->id) . '">View</a>';
                }),
                ActionButton::make('Edit')->setAttributes(function() {
                    return [
                        'class' => 'btn btn-primary'
                        'href' => route('edit', $record->id)
                        'wire:click' => 'openModal'
                    ];
                })
            ]),
        // Add more column groups as needed
    ];
}

In this example, we have a column group 'User Details' with two columns: 'ID' and 'Name'.

Currently, we do not support filtering or sorting on column groups, and there are no plans to add support for this in the future. However, feel free to create a PR if you wish to propose adding this feature

Remember, the ColumnGroup class contains instances of the BaseColumn class, so it can contain any type of column, including Column and ActionButton instances.

Last updated