Sometimes we need to hold some values from model in data- attributes of tag. But we can't use $data special variable in cell's htmlOptions attributes. Instead of holding data in cell, we can generate data- attributes for rows (tr). For this purpose CGridView has special attribute rowHtmlOptionsExpression.
<?php
$this->widget( 'zii.widgets.grid.CGridView',
[
'id' => 'my-grid',
'dataProvider' => $model->search(),