Skip to content

Commit 2545bf2

Browse files
committed
Update readme
1 parent 7946bfa commit 2545bf2

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

README.md

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -192,9 +192,9 @@ public function columns(): array
192192
{
193193
return [
194194
Column::make('Type') // Column text and optional column name, column name will be snake case of text if not defined
195-
->sortable() // Whether or not the heading can be clicked to sort
195+
->sortable(), // Whether or not the heading can be clicked to sort
196196
Column::make('Name')
197-
->sortable()
197+
->sortable(),
198198
Column::make('Permissions'),
199199
Column::make('Other', 'my_other_column')
200200
->sortable() // Allows the column to interact with the sorting methods
@@ -204,6 +204,17 @@ public function columns(): array
204204
}
205205
```
206206

207+
#### Customizing Sort Behavior
208+
209+
If you need more control over the sort behavior of a column, you can pass a callback to the sortable() method:
210+
211+
```php
212+
Column::make(__('Address'))
213+
->sortable(function(Builder $query, $direction) {
214+
return $query->orderBy(UserAttribute::select('address')->whereColumn('user_attributes.user_id', 'users.id'), $direction);
215+
})
216+
```
217+
207218
#### Configuring Sort Names
208219

209220
When clicking sortable column headers, the component will use the column name to define the sorting pill in the UI, if you don't like the way the name is rendered, you can overwrite it:

0 commit comments

Comments
 (0)