How do add data-id in below function:
GridView::widget([
'dataProvider' => $dataProvider,
'columns' => [
[
'contentOptions' => ['class' => "text-center"],
'attribute' => 'scale',
"format"=>"Html",
"value"=>function($model){
return '<div class="myClass" data-id="'.$model->id.'">'.$model->scale.'</div>';
}
],
],
]);
Here is data-id attribute which is not shown in the browser:
"value"=>function($model){
return '<div class="myClass" data-id="'.$model->id.'">'.$model->scale.'</div>';
}
You need to change the
formatfor the column torawfor the columnEDIT
Apart from returning the
htmllike,You can use the
yii\helpers\Html::tag($name,$content,$options[])to create a div tag see below.