简体   繁体   English

Yii2 活动数据提供程序分页无法正常工作

[英]Yii2 active dataprovider pagination is not working properly

I have a yii2 list view in my website.And i have to load around 5000 records.我的网站上有一个 yii2 列表视图。我必须加载大约 5000 条记录。 My search filter is like我的搜索过滤器就像

$query = Car::find();
$dataProvider = new ActiveDataProvider([
            'query' => $query,
            'pagination' => [
                'pageSize' => 10,
            ],
        ]);
$this->load($params);

I have applied a page size of 10 to the active data provider.But still the page loads the entire 5000 records.So taking too much time to load the web page.我对活动数据提供程序应用了 10 的页面大小。但页面仍然加载了整个 5000 条记录。所以加载网页需要太多时间。 I want to load 10 records first fast and then each pages through pagination.我想先快速加载 10 条记录,然后通过分页来加载每个页面。

As Documentation says this must be a pagesize property, not a pageSize .正如文档所说,这必须是pagesize属性,而不是pageSize Here is the link: Class yii\\data\\ActiveDataProvider Try to change this:这里是链接: Class yii\\data\\ActiveDataProvider尝试改变这个:

$dataProvider = new ActiveDataProvider([
            'query' => $query,
            'pagination' => [
                'pageSize' => 10,
            ],
        ]);

to this:对此:

$dataProvider = new ActiveDataProvider([
            'query' => $query,
            'pagination' => [
                'pagesize' => 10,//<---------
            ],
        ]);

Hope it helps.希望能帮助到你。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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