A
A
Alexander N++2014-07-21 01:32:42
Yii
Alexander N++, 2014-07-21 01:32:42

Why does Yii1 incorrectly paginate a GridView by referring to the main page?

There is a grid on the it/task/index page

$this->widget('zii.widgets.grid.CGridView', array(
  'id' =>'grid-task',
  'dataProvider' => $dataProvider,
  'columns' => array('_id')
));

When you go to page 2, the address is like this
it/index/Task_page/2 and it should be like this it/task/index/Task_page/2.
The controller code is simple
$model = new Task;
    $dataProvider = new EMongoDataProvider($model , array(
      'criteria' => array(
        'condition' => array(),
        'sort' => array(),
        'skip' => 1,
        'limit' => 1
      ),
    ));
    $this->render('task/index', compact('dataProvider'));

Maybe everything from the path to the view.
For some reason, the view only shows when the path is specified through a slash, in other projects it was not necessary to do this

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexander N++, 2014-07-21
@sanchezzzhak

In general, I found the reason.
My controller is inherited from its own class, which is inherited from the base.
I didn't add
parent::__construct($id, $module); in the constructor;
It is $id that allows the framework to understand where to get templates from.

public function __construct($id,$module = null)
  {
    $this->to_page = app()->user->getState('to_page', app()->params['to_page']);
    parent::__construct($id, $module);
  }

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question