gpt4 book ai didi

Yii2 GridView 小部件按 desc 顺序排序

转载 作者:行者123 更新时间:2023-12-04 02:23:36 25 4
gpt4 key购买 nike

我有一个像这样的 GridView

 <?= GridView::widget([
'dataProvider' => $dataProvider,
'columns' => [
['class' => 'yii\grid\SerialColumn'],


'movie.movie_name',
'start_date',
'end_date',
'theatre.theatre_name',
'screen.screen_name',
'time.start_time',

['class' => 'yii\grid\ActionColumn'],
],
]); ?>

如何根据 start_date 降序排列它们?

最佳答案

在搜索模型中添加sort属性:

public function search($params)
{
...

$dataProvider = new ActiveDataProvider([
'query' => $query,
'sort'=> ['defaultOrder' => ['start_date' => SORT_DESC]]
]);
....
}

关于Yii2 GridView 小部件按 desc 顺序排序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31400087/

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