I want set an id for td and obtain something like this:
<td id="3" >name</td>
but with this setting:
'value'=>'Yii::app()->jdate->date("d M y",(int) strtotime($data->create_date))',
'htmlOptions'=>array('id' => '$data->id'),
I get this:
<td id="$data->id" >name</td>
Why $data->id evaluated as string?
Try something like give on this link
If you don’t want to extend the framework classes, you could just wrap your content in a div and apply the ID to that instead of the table cell itself.
return CHtml::tag('div', array('id'=>$data->id),
Yii::app()->jdate->date("d M y",(int) strtotime($data->create_date)));
So, what is the htmlOptions usage in CGridColumn?
its a different one. htmlOptions is a property for CGridView where you can define html options for CgridView.
SO, if you want to set a id for CgridView then you can easily do it by ‘id’=>‘test’
But as per your code you was trying to add dynamic id for column for cgridview.Which will be done by as i have suggested in my previous comment.
in your code you are setting htmlOption for column for CGridView.
So, this is a difference here.
But in api is:
CDataColumn is extended from [color="#FF0000"]CGridView [/color]CGridColumn hence CDataColumn have an property named $htmlOptions.
The htmlOptions attribute doesn’t take a callback function, so you can’t generate different values for each row. It’s used for static configuration that applies to every row.
Dear friend, can you take an example of htmlOptions usage in CDataColumn, please?
Yes i do agree with you and yes you can set htmlOptions also for CDataColumn.And there is nothing wrong with it.
Suppose you are adding class attribute
'htmlOptions'=>array('class' => 'testing'),
and it will work.
But the thing is that you have to add dynamic value in id attribute field. Which is going to be pass in array. So, there is a issue for parsing a variable.
That’s why i have suggested to overwrite this class.So easily you can set it dynamic.