@@ -214,18 +214,17 @@ It's possible to use custom styles and scripts:
214
214
To enable server-side processing add ` DataTableAction ` to controller like this:
215
215
216
216
``` php
217
- class SomeController extends Controller
218
- {
219
- public function actions()
220
- {
221
- return [
222
- 'datatables' => [
223
- 'class' => 'nullref\datatable\DataTableAction',
224
- 'query' => Model::find(),
225
- ],
226
- ];
227
- }
228
-
217
+ class SomeController extends Controller
218
+ {
219
+ public function actions()
220
+ {
221
+ return [
222
+ 'datatables' => [
223
+ 'class' => 'nullref\datatable\DataTableAction',
224
+ 'query' => Model::find(),
225
+ ],
226
+ ];
227
+ }
229
228
}
230
229
```
231
230
@@ -260,17 +259,61 @@ public function actions()
260
259
],
261
260
];
262
261
}
263
-
264
262
```
265
263
266
264
If you need to get some relation data you can call ` join ` or similar methods from ` $query ` in ` applyFilter ` closure.
267
265
268
266
And add options to widget:
269
267
270
268
``` php
271
- <?= \nullref\datatable\DataTable::widget([
272
- /** ... */
273
- 'serverSide' => true,
274
- 'ajax' => '/site/datatables',
275
- ]) ?>
269
+ <?= \nullref\datatable\DataTable::widget([
270
+ /** ... */
271
+ 'serverSide' => true,
272
+ 'ajax' => '/site/datatables',
273
+ ]) ?>
274
+ ```
275
+
276
+
277
+ ## Extra columns
278
+
279
+ If need to use some custom fields from your model at your render function at column you could pass ` extraColumns ` param.
280
+
281
+ It available at DataTable widget, column and server side action definition:
282
+
283
+ ``` php
284
+ <?= \nullref\datatable\DataTable::widget([
285
+ /** ... */
286
+ 'data' => $dataProvider->getModels(),
287
+ 'extraColumns' => ['customPrice'],
288
+ 'columns' => [
289
+ [
290
+ 'title' => 'Custom column',
291
+ 'extraColumns' => ['customField'],
292
+ 'render' => new JsExpression($customColumnRender),
293
+ ],
294
+ ],
295
+ ]) ?>
296
+ ```
297
+
298
+ ``` php
299
+ class SomeController extends Controller
300
+ {
301
+ public function actions()
302
+ {
303
+ return [
304
+ 'datatables' => [
305
+ 'class' => 'nullref\datatable\DataTableAction',
306
+ 'query' => Model::find(),
307
+ 'extraColumns' => ['customPrice'],
308
+ ],
309
+ ];
310
+ }
311
+ }
312
+ ```
313
+
314
+ ``` php
315
+ <?= \nullref\datatable\DataTable::widget([
316
+ /** ... */
317
+ 'extraColumns' => ['customPrice'],
318
+ ]) ?>
276
319
```
0 commit comments