繁体   English   中英

分页按钮在 gridview Yii2 中不起作用

[英]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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM