diff --git a/edit-column.md b/edit-column.md index d778e78..2cf9542 100644 --- a/edit-column.md +++ b/edit-column.md @@ -55,3 +55,28 @@ Then create your view on `resources/views/users/datatables/name.blade.php`. ```php Hi {{ $name }}! ``` + + + +## 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(); +}); +```