Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How i can change limit in output? #15

Open
dsidorenko opened this issue Aug 11, 2016 · 4 comments
Open

How i can change limit in output? #15

dsidorenko opened this issue Aug 11, 2016 · 4 comments
Labels

Comments

@dsidorenko
Copy link

dsidorenko commented Aug 11, 2016

Hello!
Default limit 20,
I set limit ?page=1&per-page=50
but 50 is max value
where i can disable pagination?

@dsidorenko
Copy link
Author

dsidorenko commented Aug 16, 2016

I saw it, but did not understand where I have to write these lines?)

<?php
namespace rest\versions\v1\controllers;

use yii\data\ActiveDataProvider;
use yii\filters\auth\QueryParamAuth;
use yii\rest\ActiveController;

class ModelsController extends ActiveController
{

    public $modelClass = 'common\models\Models';

    public function behaviors()
    {
        $behaviors = parent::behaviors();
//        $behaviors['authenticator'] = [
//            'class' => QueryParamAuth::className(),
//        ];
        return $behaviors;
    }
    public function actionIndex()
    {
        return new ActiveDataProvider([
            'pageSizeLimit' => [0, 50],
        ]);
    }
}

does not work

@dsidorenko
Copy link
Author

dsidorenko commented Aug 16, 2016

I saw it, but did not understand where I have to write these lines?)

<?php
namespace rest\versions\v1\controllers;

use yii\data\ActiveDataProvider;
use yii\filters\auth\QueryParamAuth;
use yii\rest\ActiveController;

class ModelsController extends ActiveController
{

    public $modelClass = 'common\models\Models';

    public function behaviors()
    {
        $behaviors = parent::behaviors();
        return $behaviors;
    }
    public function actionIndex()
    {
        return new ActiveDataProvider([
            'pageSizeLimit' => [0, 50],
        ]);
    }
}

does not work

@githubjeka
Copy link
Owner

githubjeka commented Aug 16, 2016

See API ActiveDataProvider and his pagination. After see property of Pagination.

 public function actionIndex()
    {
        return new ActiveDataProvider([
            'pagination' => [
                 'defaultPageSize' => 20 // to set default count items on one page
                 'pageSize' => 25 //to set count items on one page, if not set will be set from defaultPageSize
                 'pageSizeLimit' => [1, 50], //to set range for pageSize 
             ],
        ]);
    }

To disable pagination:

 public function actionIndex()
    {
        return new ActiveDataProvider([
            'pagination' => false,
        ]);
    }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants