0
votes

In table I have a columns where data like 2016-12-13 10:51:03 which output in gridview. I put datepicker

[
          'attribute'=>'order_statusUpdatedAt',
          'value'=>'order_statusUpdatedAt',
          'format'=>'raw',
          'filter'=>DatePicker::widget([
          'model'=>$searchModel,
          'attribute'=>'order_statusUpdatedAt',
          'clientOptions'=>
             [
              'autoclose'=>true,
              'format'=>'yyyy-mm',
             ]
    ]),
],

I want to search all lines which have like 2016-12. How could I search for partial matches?

OrderSearch

`public function search($params) { $query = Order::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([

'order_createdAt' => $this->order_createdAt]);

    return $dataProvider;
}
1
Where do you want to search in? - SiZE
@SiZE in gridview. - cruim
where is you r searchModel code? - Mohan Prasad
@MohanPrasad add to question - cruim
you want to search based on the date 2016-12? Mean to say when you enter the date 2016-12 you need to get all the data which has 2016/12? - Mohan Prasad

1 Answers

0
votes

After your grid conditions add this bit of code.

 $query->andFilterWhere(['like','order_createdAt', $this->order_statusUpdatedAt]);

the third condition should be the attribute where you have specified in your search field attribute. So the search data you entered in the search field will be like the data from your database, i.e. 'order_created' in your case.

Hope this helps you..