How To Assign Dynamic Data To Cdatacolumn Htmloptions

I have a CGridView table. I would like to add data-id attribute to the <td> element. Looking at the CDataColumn I have the following column:




'columns'=>array(

                array(

                    'name'  => 'article_title',

                    'value' => '$data->article_id . ". " . $data->article_title',

                    'htmlOptions' => array("data-id" => $model->article_id),

                )

            ),



htmlOptions from the above code fail as $model->article_id is null. How can I access the value of the current data row?

Thanks

CGridView::$rowHtmlOptionsExpression was added in 1.1.13:




	'columns'=>array(...),

	'rowHtmlOptionsExpression'=>'array(

		"data-id"=>$data->article_id,

	)',



Yes, it needs to be an array inside a string.

This is not what I am looking for. This adds data-id to the <tr> element and i need to add data-id to the <td> element so I just need to understand how htmlOptions on the columns work with dynamic data!

htmlOptions doesn’t work with dynamic data. article_id is part of a row in your database, so you can only attach it to the row element in your HTML table. It’s easy to get the value from within the column.


<script>

  $("td").parents("tr").data("id");

</script>