Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions edit-column.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,3 +55,28 @@ Then create your view on `resources/views/users/datatables/name.blade.php`.
```php
Hi {{ $name }}!
```


<a name="selected-column"></a>
## Edit only the requested Columns

> {tip} You can skip editing the columns that are not in your requested payload by using `editOnlySelectedColumns` before using `editColumn`
```php
use DataTables;

Route::get('user-data', function() {
$model = App\User::query();

return DataTables::eloquent($model)
->editColumn('id', function () {
return view('users.datatables.id'); // View will always be rendered
})
->editOnlySelectedColumns()
->editColumn('name', function () {
return 'Hi ' . $user->name . '!'; // View will only be rendered if the column is in the payload
only if in the payload
})
->toJson();
});
```