2017-09-12 3 views
0

yii2 내보내기 menu.it이 제대로 작동하지만 검색이 제대로 작동하지 않습니다 .i can not what whats going wrong? 그것을 해결하기 위해 도와주세요 ... 여기검색이 작동하지 않습니다. yii2 gridview

<?php 
     $gridColumns = [ 
     [ 
     'class' => 'yii\grid\SerialColumn', 
     ], 
     'name', 
     'company_mail',  
     'created', 
     'modified', 
     'modified_by_id', 
     ['class' => 'yii\grid\ActionColumn', 'urlCreator'=>function(){return '#';}], 

    ]; ?> 

<?php 
echo ExportMenu::widget([ 
'dataProvider' => $dataProvider, 
'filterModel'=>$searchModel, 
'columns' => $gridColumns, 
'target' => ExportMenu::TARGET_BLANK, 
    ]); 

?> 
<?php 
echo GridView::widget([ 
'dataProvider' => $dataProvider, 
'filterModel' => $searchModel, 
'columns' => $gridColumns, 
]); 
?> 

답변

0

, $의 dataProvider = $ searchModel-> 검색에 기능을 다음에 추가 코드 -이다 Yii :: $ app-> request-> queryParams); 이 라인은 실수로 주석 처리되었습니다.

감사합니다 ...

0

이 (검색 모델 companiesController.php에서

public function search($params) 
    { 
     $query = YourModel::find(); 

     $dataProvider = new ActiveDataProvider([ 
      'query' => $query, 
      'sort' => [ 
       'defaultOrder' => [ 

       ] 
      ], 
     ]); 

     $this->load($params); 

     if (!$this->validate()) { 
      // uncomment the following line if you do not want to return any records when validation fails 
      // $query->where('0=1'); 
      return $dataProvider; 
     } 


     $query->andFilterWhere(['like', 'name', $this->name]) 
      ->andFilterWhere(['like', 'company_mail', $this->company_mail]) 
      ->andFilterWhere(['like', 'modified', $this->modified]) 
      ->andFilterWhere(['like', 'created', $this->created]) 
      ->andFilterWhere(['like', 'modified_by_id', $this->modified_by_id]); 

     return $dataProvider; 
    } 
+0

감사합니다 ...하지만 그것은 작동하지 않습니다 ...이 코드는 이미 내 프로젝트에 존재합니다 .... .... 다른 것을 제안하십시오 – Darsh