My gridview data
day modeler total
2018-1-05 ABC 5
2018-1-06 DEF 8
2018-1-06 CAB 3
2018-1-06 GHI 3
2018-1-06 KLM 3
I have a gridview like this. Right now and can only filter modeler one by one. Can I have a multiple line searchbox and just paste in "ABC DEF CAB" and it will filter 3 results like below?
day modeler total
2018-1-05 ABC 5
2018-1-06 DEF 8
2018-1-06 CAB 3
My controller
public function actionIndex()
{
$searchModel = new ModelerSearch();
$dataProvider = $searchModel->search(Yii::$app->request->queryParams);
return $this->render('index', [
'searchModel' => $searchModel,
'dataProvider' => $dataProvider,
]);
}
My search model
public function search($params)
{
$query = Modeler::find();
// add conditions that should always apply here
$dataProvider = new ActiveDataProvider([
'query' => $query,
]);
$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;
}
// grid filtering conditions
$query->andFilterWhere([
'id' => $this->id,
]);
$query->andFilterWhere(['like', 'modeler', $this->modeler])
->andFilterWhere(['like', 'total', $this->total]);
return $dataProvider;
}
}
Thank you!
"ABC"it should show you matching record and if you enter"ABC DEF"with space it should show you 2 records matching either one of them ? if it is correct you need to add the code related to yoursearchmodel,viewand controlleractionsearch()function from theSearchModel