A
A
akula222017-03-07 16:12:07
Yii
akula22, 2017-03-07 16:12:07

How to make a different cell background in a non-standard order in gridview?

In the grid, you need to make a different background for the cells, but not as usual, as well as 1.2 background1 and 3.4 background2, and so on
, you need to shaman here

'rowOptions'=>function ($model, $key, $index, $grid){
                $class=$index % 2 ? 'odd' : 'even';
                return [
                    'key'=>$key,
                    'index'=>$index,
                    'class'=>$class
                ];
            },

Prompt solution

Answer the question

In order to leave comments, you need to log in

2 answer(s)
M
Maxim Timofeev, 2017-03-07
@akula22

And what for yii to pull? This is a task for css and :nth-of-type

tr:nth-of-type(1), tr:nth-of-type(2) {background-color:red;}
tr:nth-of-type(3), tr:nth-of-type(4) {background-color:green;}

A
akula22, 2017-03-07
@akula22

<tbody class="ui-sortable">
<tr data-key="7" class="ui-sortable-handle"><td style="border-top:1px solid; ">1</td><td ><img src="/upload/images/team/586246181f77b.png" alt="" style="width:35px;height:35px;"> Zenit St. Petersburg - [ robot_dqaTH ] </td></tr>
<tr data-key="1" class="ui-sortable-handle"><td >2</td><td><img src="/upload/images/team/5894d64081ada.png" alt="" style="width:35px;height:35px;"> Amkar Perm - [ akula22 ] </td></tr>

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question