Hello there,
I have to add several default buttons to my CButtonColumn, so I began create a component: MyCButtonColumn.
But I can’t find the way to make it work as I want/need.
Actually, I have:
class MyCButtonColumn extends CButtonColumn {
/**
* Default template to use
*/
public $template = '{view}{graph}';
public function init()
{
parent::init();
$this->graphButton();
}
/**
* Default params for graph button
*/
private function graphButton()
{
$this->buttons['graph'] = array(
'label' => 'Graph',
'imageUrl' => 'images/graph.png'
);
}
}
First, I hate my init() function, I’ve to add all my buttons in it, I guess there is a nicest method to do that, but didn’t find it.
And when using the button in a cgridview, I can’t change any parameter…
array(
'class'=>'MyCButtonColumn',
'template' => '{graph}',
'buttons' => array(
'graph' => array(
'url'=>'Yii::app()->createUrl("controller/view", array("id"=>$data->id))',
),
),
),
),
This doesn’t do anything else than displaying my default graph button.
Is it possible to make it work as I want or must I put my "default" buttons in each view and forget MyCButtonColumn ?
Regards