kartik-v / yii2-dynagrid

Turbo charge the Yii 2 GridView with personalized columns, page size, and themes.
http://demos.krajee.com/dynagrid
Other
74 stars 66 forks source link

pagination 0 #81

Closed dudunegrinhu closed 9 years ago

dudunegrinhu commented 9 years ago

Hi, I'm not being able to show all results in the grid. I'm doing:

$dataProvider = new ActiveDataProvider([ 'query' => $query, 'pagination' => [ 'pagesize' => 0 // in case you want a default pagesize ] ]);

but it still showing 10 results instead of all. What am I missing?

andjelko commented 9 years ago

you must also set in modules

    'modules' => [
        'dynagrid'=> [
             'class'=>'\kartik\dynagrid\Module',
             'defaultPageSize'=>0, //this line
         ],
adamwinn commented 6 years ago

But what if we want to have 2 dynagrids with 2 different defaultPageSize? How can that be achieved?

It looks like the module configuration is set for all dynagrids. Also, it seems pagination in the DataProvider gets overridden by the module config. I don't know how to have 2 different dynagrids with 2 different page sizes.

lieszkol commented 5 years ago

If you need to set differing default page sizes for your dynagrids (a common scenario, i would think), then unfortunately something like $dataProvider->setPagination(['pageSize' => 100]); does not work because of line 613 in DynaGrid.php:

if (!isset($this->_pageSize) || $this->_pageSize === null) {
    $this->_pageSize = $this->_module->defaultPageSize;
}

You can, however, set a default page size in your configuration:

$config = 
    ['modules' => 
        ['dynagrid'=> 
            [
                'class'=>'\kartik\dynagrid\Module',
                'defaultPageSize'=>20,....

And you can change this "on-the-fly" in your code before generating your datagrid:

\Yii::$app->getModule('dynagrid')->defaultPageSize = 50;
echo DynaGrid::widget([...