I'm using the same code as I used to add in ActiveForm, but it doesn't work:
What i sthe correct way to add jui datepicker in filter field for gridview?
<?= GridView::widget([
'dataProvider' => $dataProvider,
'filterModel' => $searchModel,
'columns' => [
['class' => 'yii\grid\SerialColumn'],
'list_id',
[
'attribute' => 'channel',
'value' => 'channel.title',
],
[
'attribute' => 'list_date',
'value' => 'list_date',
'filter' => \yii\jui\DatePicker::widget(\yii\jui\DatePicker::className(), ['language' => 'ru', 'dateFormat' => 'dd-MM-yyyy']),
],
'make_date',
['class' => 'yii\grid\ActionColumn'],
],
]); ?>
I tried this and works fine:
[
'attribute' => 'updated_at',
'value' => 'updated_at',
'filter' => \yii\jui\DatePicker::widget([
'model'=>$searchModel,
'attribute'=>'updated_at',
'language' => 'ru',
'dateFormat' => 'dd-MM-yyyy',
]),
'format' => 'html',
],
Then, you must add this line to your Search Model:
$query->andFilterWhere([
...
'DATE(updated_at)' => $this->updated_at,
]);
Make sure the date formats are identical.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With