I need to customize some behaviors in CDataColumn. However, CGridView::createDataColumn() and CGridView::initColumns() use CDataColumn component bu default. So how can I do that with as less/clean code as possible?
I need to customize some behaviors in CDataColumn. However, CGridView::createDataColumn() and CGridView::initColumns() use CDataColumn component bu default. So how can I do that with as less/clean code as possible?
Create your own class that extends CDataColumn, and use that in your CGridView like you would with class based columns
'columns' => array(
'attribue1',
'attribue2',
'attribue3',
array(
'class' => 'application.components.MyDataColumn',
),
)
Thanks Asgaroth. That works! Although it is a little bit verbose to specify the ‘class’ attribute for each DataColumn.
Well another idea could be to extend CGridView and overwrite CGridView::createDataColumn() and CGridView::initColumns() so that it uses your custom data column instead.
Thanks Asgaroth. I’m taking this way actually. Just not sure if there are some side effects at some point.
I dont see any side effects, inheritances is wonderfull
just take care when upgrading the framework, as may be the CGridView can change a little, but its not a big deal anyway.