B
B
bizzonaru2017-02-04 11:08:06
Yii
bizzonaru, 2017-02-04 11:08:06

How to reverse order yii\grid\SerialColumn?

It is necessary that the numbers are displayed in reverse order - from a larger value to a smaller one. Can this be done somehow?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
M
Maxim Fedorov, 2017-02-04
@qonand

In the standard implementation, this is not possible. If you need to implement the reverse order - make your own SerialColumn, see how it works in the standard implementation

M
Maxim Timofeev, 2017-02-06
@webinar

Maxim Fedorov is right. Copy the standard class and overwrite this method:

protected function renderDataCellContent($model, $key, $index)
    {
        $pagination = $this->grid->dataProvider->getPagination();
        if ($pagination !== false) {
            return $pagination->getOffset() + $index + 1;
        } else {
            return $index + 1;
        }
    }

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question