gpt4 book ai didi

gridview - 如何添加 Yii2 jui datepicker 到 GridView 中的过滤字段

转载 作者:行者123 更新时间:2023-12-02 19:15:35 25 4
gpt4 key购买 nike

我使用的代码与在 ActiveForm 中添加的代码相同,但它不起作用:

在 gridview 的过滤器字段中添加 jui datepicker 的正确方法是什么?

<?= 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'],
],
]); ?>

最佳答案

我尝试过这个并且工作正常:

[
'attribute' => 'updated_at',
'value' => 'updated_at',
'filter' => \yii\jui\DatePicker::widget([
'model'=>$searchModel,
'attribute'=>'updated_at',
'language' => 'ru',
'dateFormat' => 'dd-MM-yyyy',
]),
'format' => 'html',
],

然后,您必须将此行添加到您的搜索模型中:

$query->andFilterWhere([

...

'DATE(updated_at)' => $this->updated_at,
]);

确保日期格式相同。

关于gridview - 如何添加 Yii2 jui datepicker 到 GridView 中的过滤字段,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27563120/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com