> For the complete documentation index, see [llms.txt](https://boredprogrammers.gitbook.io/laragrid/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://boredprogrammers.gitbook.io/laragrid/column-group/usage.md).

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

```php
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.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://boredprogrammers.gitbook.io/laragrid/column-group/usage.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
