File tree
Expand file treeCollapse file tree1 file changed
+33
-1
lines changed Expand file treeCollapse file tree1 file changed
+33
-1
lines changed Original file line number | Diff line number | Diff line change |
---|
@@ -46,16 +46,48 @@ Route::get('user-data', function() {
|
46 | 46 | $model = App\User::query();
|
47 | 47 |
|
48 | 48 | return DataTables::eloquent($model)
|
49 |
| -->editColumn('name', 'users.datatables.into') |
| 49 | +->editColumn('name', 'users.datatables.name') |
50 | 50 | ->toJson();
|
| 51 | + |
51 | 52 | });
|
52 | 53 | ```
|
53 | 54 |
|
54 | 55 | Then create your view on `resources/views/users/datatables/name.blade.php`.
|
| 56 | + |
55 | 57 | ```php
|
56 | 58 | Hi {{ $name }}!
|
57 | 59 | ```
|
58 | 60 |
|
| 61 | +<a name="view-with-data"></a> |
| 62 | +## Edit Column with View and Data |
| 63 | + |
| 64 | +> {tip} You can use view to render your added column by passing the view path as the second argument on `editColumn` api. |
| 65 | +
|
| 66 | +```php |
| 67 | +use DataTables; |
| 68 | + |
| 69 | +Route::get('user-data', function() { |
| 70 | +$model = App\User::query(); |
| 71 | + |
| 72 | +$externalData = 'External'; |
| 73 | + |
| 74 | +return DataTables::eloquent($model) |
| 75 | +->editColumn('name', ['users.datatables.name', [ |
| 76 | +'externalData' => $externalData, |
| 77 | +]]) |
| 78 | +->toJson(); |
| 79 | + |
| 80 | +}); |
| 81 | +``` |
| 82 | + |
| 83 | +Then create your view on `resources/views/users/datatables/name.blade.php`. |
| 84 | + |
| 85 | +```php |
| 86 | +Hi {{ $name }}! |
| 87 | + |
| 88 | +Here is some external data: {{ $externalData }}. |
| 89 | +``` |
| 90 | + |
59 | 91 |
|
60 | 92 | <a name="selected-column"></a>
|
61 | 93 | ## Edit only the requested Columns
|
|
You can’t perform that action at this time.
0 commit comments