CButtonColumn $data and $row in button=>options clause, not ony in url and visible


'buttonID' => array(

    'label'=>'...',     // text label of the button

    'url'=>'...',       // a PHP expression for generating the URL of the button

    'imageUrl'=>'...',  // image URL of the button. If not set or false, a text link is used

    'options'=>array(...), // HTML options for the button tag

    'click'=>'...',     // a JS function to be invoked when the button is clicked

    'visible'=>'...',   // a PHP expression for determining whether the button is visible

)


In the PHP expression for the 'url' option and/or 'visible' option, the variable $row refers to the current row number (zero-based), and $data refers to the data model for the row. 

quote from docs

Is it will not be useful have ability to do something like that




'some_button' => array(

       'click' =>  "call_my_func($data['ID'])"));



I’ve wanted this a few times, I even wrote an extension to make it possible to do evaluated CHtml::ajaxLink cells.

I think a better way to go (IMHO) is to add an "as expression" option, then you could do this:




//php 5.3

'label'=>'...',     // text label of the button

'asExpression'=>function($data, $row) {

  return array(

    'url' => $data->id,

    'imageUrl' => $data->image,

  )

}

//php 5.x

'label'=>'...',     // text label of the button

'asExpression'=> "array(

    'url' => \$data->id,

    'imageUrl' => \$data->image,

  )",



The renderCell method could just merge this array back in if you’ve set anything.