March 10 2013

Yii row number in CGridView

Tagged Under :

Yii
In Yii CGridView it doesn’t provide absolute row number in all the pages.

The easy way is write the a calculation method inside the column to show the column number.

$this->widget('zii.widgets.grid.CGridView',
  array(
    'columns' => array(
      array(
        'header' => 'No.',
        'value' => '$this->grid->dataProvider->pagination->currentPage * $this->grid->dataProvider->pagination->pageSize + ($row+1)',
      ),
    ),
  )
);
Why the $row + 1, because $row starts from the 0.

Make a Comment

You must be logged in to post a comment.