嗨,我有一個yii代碼,我可以顯示模型中的數據,但搜索欄沒有在gridview中顯示,請大家幫忙。GridView中的YII2中的過濾器設置
的GridView代碼:
<?= GridView::widget([
'dataProvider' => $dataProvider,
'filterModel' => $searchModel,
'columns' => [
['class' => 'yii\grid\SerialColumn'],
// 'emp_attendance_pid',
[
'label' => 'Employee ID',
'attribute' => 'emp_history_id',
'value' => 'emp_history_id',
],
[
'label' => Yii::t('app','First Name'),
// 'attribute' => 'emp_history_id',
'value' => 'empHistory.emp_first_name',
'filter' => ArrayHelper::map(app\modules\employee\models\EmpInfo::find()->all(), 'emp_info_id', 'emp_first_name')
],
[
'label' => Yii::t('app','Last Name'),
// 'attribute' => 'emp_history_id',
'value' => 'empHistory.emp_last_name',
'filter' => ArrayHelper::map(app\modules\employee\models\EmpInfo::find()->all(), 'emp_info_id', 'emp_last_name')
],
在這裏你可以看到過濾器,在我能夠使用arrayhelper來獲取數據,但我需要讓我在搜索框中我給的數據,搜索盒子也沒有來,只有下拉正在提供
請出示相關的控制器/動作..和相關ModelSearch .. – scaisEdge
$ query = EmpHistory :: find(); $ dataProvider = new ActiveDataProvider(['''''''''>'$ query',';'); $ this-> load($ params); (!$ this-> validate()){ return $ dataProvider;如果(!$ this-> validate()){ 返回$ dataProvider; ($'this-> emp_history_pid'=> $ this-> emp_history_pid,'emp_history_id'=> $ this-> emp_history_id,'emp_history_date'=> $ this-> dbDateSearch($ this-> emp_history_date), } $ query-> andFilterWhere ]); $ query-> andFilterWhere(['like','emp_history_process',$ this-> emp_history_process]) - > andFilterWhere(['like','emp_history_remarks',$ this-> emp_history_remarks]); – Paventhan
這是我的搜索動作 – Paventhan