[英]pagination button is not working in gridview Yii2
分頁按鈕在 gridview Yii2 中不起作用。 如果我單擊第 2 頁按鈕,它會移動到帶有 URL(http://localhost/testyii/frontend/web/products/view?page=2&per-page=3)的其他頁面,並且它的顯示錯誤(404 Not found URL 不是在此服務器上找到)。 我在這里錯過了什么代碼。 這是我的 controller:-
public function actionView()
{
$WmProducts = WmProducts::find();
$dataProvider = new ActiveDataProvider ([
'query' =>$WmProducts,
'pagination' => ['pageSize'=>3],
]);
return $this->render('view', [
'dataProvider' =>$dataProvider]);
}
這是查看頁面:-
<?php
use yii\grid\GridView;
use yii\data\ActiveDataProvider;
use yii\widgets\ActiveForm;
use yii\helpers\Html;
use yii\widgets\Pjax;
use app\models\Client;
?>
<?php
echo GridView::widget([
'dataProvider' => $dataProvider,
'columns' => [
'id',
[
'attribute' => 'name',
'format' => 'text'
],
[
'attribute' => 'wholesale_price',
'format' => 'text'
],
[
'attribute' => 'is_retail',
'format' => 'text'
],
[
'attribute' => 'distributor_price',
'format' => 'Text'
]
]
]);
?>
如何解決它。 以及我在查看頁面中錯過的內容。
如果分頁組件將您發送到/view...
而不是/index...
URL,您似乎已經以某種方式修改了分頁組件。 您是否在view.php
文件中使用此 GridView ? 如果是,分頁將假定一個作為基礎 URL 並且您應該指定哪個是正確的 URL 使用。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.