@@ -214,18 +214,17 @@ It's possible to use custom styles and scripts:
214214To enable server-side processing add ` DataTableAction ` to controller like this:
215215
216216``` 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+ }
229228}
230229```
231230
@@ -260,17 +259,61 @@ public function actions()
260259 ],
261260 ];
262261}
263-
264262```
265263
266264If you need to get some relation data you can call ` join ` or similar methods from ` $query ` in ` applyFilter ` closure.
267265
268266And add options to widget:
269267
270268``` 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+ ]) ?>
276319```
0 commit comments