M
M
Mark2017-09-02 17:33:15
Yii
Mark, 2017-09-02 17:33:15

How to make dropdown-input instead of text in yii\grid\SerialColumn Yii2?

Hello. There was a problem, the fact is that I want the yii\grid\SerialColumn to have not an input with the text type, but a dropdown, so that only specific values ​​can be selected. Those. the cell itself is a status cell, and manually entering the status name is very inconvenient, so it's better to provide a dropdownlist.
How can this be implemented?
Visual example:
With input(as is):
zQWu4UC.jpg
With select(as needed):
ZFdE9Uf.jpg

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
Maxim Timofeev, 2017-09-02
@MarkLb

['attribute'=>'someAttribute','filter'=>[1,2,4,5,6,'вася','Зеленый']]

This is for yii\grid\DataColumn, for yii\grid\SerialColumn dropdown is not provided, since it makes no sense. And the usual input type text is not there, since there is no point in it. It's just line numbering. And why this is necessary is not clear. But you have the right to demolish yii\grid\SerialColumn and do it through yii\grid\DataColumn or override the renderFilterCell() method of yii\grid\SerialColumn, for example by making your own class, inheriting from yii\grid\SerialColumn and overriding renderFilterCell( )

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question