原文地址:
https://stackoverflow.com/questions/36937615/kartik-select2-as-filter-input-in-yii2-grid
代码如下:
引入select2插件:
use kartik\select2\Select2;
具体代码:
['attribute' => 'bank_id',
'value' => function ($model) {
return $model->bank->bank_name;
},
'contentOptions' => [
'align' => 'center',
],
'filter'=>Select2::widget(['name' => 'ApplyDepositRecordSearch[bank_id]',
'data' => \livan\distribution\models\ars\ApplyDepositRecord::bankData(),
'value' =>$searchModel->bank_id,
'options' => ['placeholder' => '请选择开户行']
])
],
效果1
下拉框效果
下拉框搜索效果
选择下拉框效果
网友评论