gpt4 book ai didi

gridview - 过滤结果分页在 yii2 gridview 中不起作用

转载 作者:行者123 更新时间:2023-12-03 06:41:40 25 4
gpt4 key购买 nike

我使用Pjax gridview,搜索结果后,当我单击分页时,结果更改为默认结果页面而不是搜索结果。我的搜索功能就像

public function search($params)
{
$query = UserLogs::find();
$dataProvider = new ActiveDataProvider([
'query' => $query,'pagination'=> ['defaultPageSize' => PAGE_SIZE],
'sort' => [
'defaultOrder' => [
'user_log_id' => SORT_DESC,
]
],
]);

$this->load($params);

if (!$this->validate()) {
return $dataProvider;
}

$query->joinWith('user');

// grid filtering conditions
$query->andFilterWhere([
'user_log_id' => $this->user_log_id,
//'user_id' => $this->user_id,
'user_logs.user_type_id' => $this->user_type_id,
'login_time' => $this->login_time,
'logout_time' => $this->logout_time,
]);

$query->andFilterWhere(['like', 'login_ip', $this->login_ip])
->andFilterWhere(['like', 'juser.firstname', $this->user_id]);

return $dataProvider;
}

编辑#1:我的 GridView 文件是:

<?php Pjax::begin(['clientOptions' => ['method' => 'POST']]);?>
<?= GridView::widget([
'dataProvider' => $dataProvider,
'filterModel' => $searchModel,
'columns' => [
['class' => 'yii\grid\SerialColumn'],

.....

['class' => 'yii\grid\ActionColumn','template' => '{view}'],
],
]); ?>
<?php Pjax::end();?>

最佳答案

将 POST 更改为 GET,这将使分页与任何其他过滤器一起工作。

关于gridview - 过滤结果分页在 yii2 gridview 中不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37720773/

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