我在我的页面中使用Kartik gridview并且过滤无法正常工作。 我已经检查了演示文稿,该文档在文档页面中给出,但我找不到任何我可以错过的内容。也没有任何错误。如果我的代码出现问题,请告诉我。谢谢!
以下是完整的视图代码:
<?php
use yii\widgets\Pjax;
use yii\helpers\Url;
use kartik\grid\GridView;
use yii\helpers\Html;
?>
<div class="card">
<?php
$gridColumns = [
['class' => 'kartik\grid\SerialColumn'],
[
'class' => 'kartik\grid\EditableColumn',
'attribute' => 'full_name',
'vAlign'=>'middle',
'headerOptions'=>['class'=>'kv-sticky-column'],
'contentOptions'=>['class'=>'kv-sticky-column'],
'editableOptions'=>['header'=>'Full name', 'size'=>'md']
],
[
'class' => 'kartik\grid\EditableColumn',
'attribute' => 'user_name',
'vAlign'=>'middle',
'headerOptions'=>['class'=>'kv-sticky-column'],
'contentOptions'=>['class'=>'kv-sticky-column'],
'editableOptions'=>['header'=>'User Name', 'size'=>'md']
],
[
'attribute'=>'balance',
'value'=>function ($model, $key, $index, $widget) {
return "<span class='badge' style='background-color: {$model->balance}'> </span> <code>" .
$model->balance . '</code>';
},
'vAlign'=>'middle',
'format'=>'raw',
'width'=>'150px',
'noWrap'=>true
],
[
'class' => 'kartik\grid\ActionColumn',
'vAlign'=>'middle',
'urlCreator' => function($action, $model, $key, $index) { return '#'; },
'updateOptions'=>['title'=>$updateMsg, 'data-toggle'=>'tooltip'],
'deleteOptions'=>['title'=>$deleteMsg, 'data-toggle'=>'tooltip'],
]
];
Pjax::begin();
echo GridView::widget([
'dataProvider'=> $dataProvider,
'filterModel' => $searchModel,
'columns' => $gridColumns,
'responsive'=>true,
'bootstrap'=>true,
'hover'=>true,
'resizableColumns'=>true,
'showPageSummary' => false,
'toolbar' => [
['content'=>
Html::a('<i class="glyphicon glyphicon-repeat"></i>', ['users'], ['data-pjax' => true, 'class' => 'btn btn-default', 'title'=>'Reset Grid'])
],
'{export}',
'{toggleData}'
],
'pjax'=>true,
'panel' => [
'heading' => '<b>Users List</b>',
'before' => '',
],
]);
Pjax::end();
?>
</div>