Closed coderovich closed 5 years ago
@coderovich please add the code of the widget usage.
sure. it's the same as for 1.0.4 version:
DataTable::widget([ 'data' => $provider->getModels(), 'tableOptions' => ['class' => 'table table-bordered table-striped dataTable'], "pageLength" => 25, 'autoWidth' => false, 'order' => [], 'columns' => [ 'name', 'en_name', 'offers', ], ], ]) ?>
@coderovich could you provide all stack trace?
yep: Error: Class 'nullref\datatable\InvalidConfigException' not found in ..\vendor\nullref\yii2-datatables\src\DataTableColumn.php:68 Stack trace:
but it trows because did't got $data...
@coderovich
Sorry, but I can't reproduce this issue at my local env.
Please, try to run my demo project.
The route to Datatables demo: /product/default/datatable
.
View file path: src/modules/product/views/default/datatable.php
.
i found the stumbling block. Error happens when column property has dynamic item rendered via callback without 'data' property :
'columns' => [
[
'title' => 'Custom Column',
'render' => new JsExpression('function render(data, type, row, meta ){
return row["foo"];
}'),
],
]
so what's reason to require 'data' property in custom column? In case while this column - is concated string from mixed data and does not have an particular data-provider.
@coderovich You are totally right, I don't even know why we miss this case before, sorry for that :( Please, try the latest version from dev-master. It should resolve this problem.
everything is ok now. Thanx for fix and sorry for my long reply.
But i think that in the next major versions it would be more convenient to do new class e.g. "nullref\datatable\CustomColumn" where 'data' column will not be. Following this, you can return required 'data' attribute to DataTableColumn.
If you think that it will be useful -- feel free to create PR.
After last update class DataTable starts throw exception: throw new InvalidConfigException(get_class($this) . '::$data must be set.');