-
Notifications
You must be signed in to change notification settings - Fork 46
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
input box tr of filter may not be rendered #55
Comments
Hello @yanhuixie |
Hey @yanhuixie |
Hi~ @ZAYEC77 Is this code snippet OK? //VIEW
$renderFileNameJs = <<<EOF1
function(data, type, row, meta) { return row['fileNameWithUrl']; }
EOF1;
$renderFileSizeJs = <<<EOF2
function(data, type, row, meta) { return (data / 1024).toFixed(1) + 'KiB'; }
EOF2;
$renderYesNoJs = <<<EOF3
function(data, type, row, meta) { return data == 0 ? '' : "<span style='color:red;'>是</span>"; }
EOF3;
<?= \nullref\datatable\DataTable::widget([
'data' => $dataProvider->getModels(),
'withColumnFilter' => true,
'columns' => [
[
'data' => 'id', 'title' => Yii::t('common', 'ID'),
'filter' => false,
],
[
'data' => 'filename', 'title' => Yii::t('common', 'File Name'),
'render' => new JsExpression($renderFileNameJs),
],
[
'data' => 'size', 'title' => Yii::t('common', 'File Size'),
'filter' => false,
'render' => new JsExpression($renderFileSizeJs),
],
[
'data' => 'packed', 'title' => Yii::t('common', 'Packed'),
'filter' => false,
'render' => new JsExpression($renderYesNoJs),
],
[
'data' => 'invalid', 'title' => Yii::t('common', 'Invalid'),
'filter' => false,
'render' => new JsExpression($renderYesNoJs),
],
[
'data' => 'createdAt', 'title' => Yii::t('common', 'Create Time')
],
],
'extraColumns' => ['fileNameWithUrl'],
'serverSide' => true,
'ajax' => Url::to(['/foo/dtsviewitem',]),
'language' => new JsExpression("{'url':'$dt_i18n'}"),
'scrollX' => false,
'scrollY' => false,
"pagingType" => "full_numbers",
"order" => new JsExpression("[[ 1, 'asc' ] ]"),
"lengthMenu" => new JsExpression("[[10,20,50,100],[10,20,50,100]]"),
"tableOptions" => ["class" => "view-upl-items table table-hover table-condensed "],
"id" => "tbl_upl_items",
"globalVariable" => true
]) ?> //CONTROLLER
class FooController extends Controller
{
public function actions(){
return [
'dtsviewitem' => [
'class' => \nullref\datatable\DataTableAction::className(),
'query' => MyAR->query(),
'extraColumns' => ['fileNameWithUrl'],
],
];
}
} |
Hey @yanhuixie 👋 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi @ZAYEC77 , thanks for your awesome plugin, it helps a lot.
We are using server-side mode, anything works like a charm excepts the filter.
We set the withColumnFilter=>true but no filter was rendered, and we have just debugged the code, and noticed something strange.
Please see https://github.com/NullRefExcep/yii2-datatables/blob/master/src/DataTable.php#L206
L206 - L216 not executed because no tr/th is rendered in the thead while L203 is executing (as Chrome debugging).
Version of Chrome : 76.0.3809.100
Version of Firefox : 67.0.4 (Same thing like chrome)
We have tried to register table.on('init.dt', func) and table.on('draw.dt', func) events to the datatable and copy/move L203 - L229 to the callback func, now the filter input box are rendered but still work not properly. After input something to filter, ajax request had sent but the response just not filtered, because the parameters inputted was not sent with the request.
That's what we found so far, hope it will be useful to you.
The text was updated successfully, but these errors were encountered: