i have in my admin view and order button column i made using the following code:
'label'=>'Order', //Text label of the button.
'url'=>'$data->id', //A PHP expression for generating the URL of the button.
'imageUrl'=>Yii::app()->request->baseUrl.'/images/to_cart.jpg', //Image URL of the button.
'options'=>array('title'=>'Add to cart','class'=>'toCart','id'=>'$data->id'), //HTML options for the button tag.
//'click'=>'alert("clicked to order");', //A JS function to be invoked when the button is clicked.
'visible'=>'Yii::app()->user->checkAccess("stock.order")', //A PHP expression for determining whether the button is visible.
The problem is that in the ‘options’ array ‘id’=>’$data->id’ is not being evaluated, it is just preinted as is, i.e the html produced thereof is … id=’$data->id’, i realised the problem might be in zii.widgets.grid.CButtonColumn on function ‘renderButton’. I added the following lines to make it work:
Thanx phtamas, that is certainly a better way to do it, i am having the same problem trying to set unique ids for the data cells (<td id=’$data->id’></td>) in cgridview, i will try and implement the same solution.