Difference between #2 and #3 of
Customize CGridView columns directly in your view

Revision #3 has been created by clapas on Aug 14, 2012, 11:19:05 AM with the memo:

Missing array_search call
« previous (#2)


Title unchanged

Customize CGridView columns directly in your view

Category unchanged


Yii version unchanged

Tags unchanged

cgridview, columns

Content changed

Very often, you will want to customize a single column, while keeping the rest untouched. There are many ways to accomplish this, but I find the following to be the easiest one:

$columns = array_keys($model->metaData->columns);
array_search('column_name', $columns)] = array(
'name' => 'column_name',
'value' => ...
$this->widget('zii.widgets.grid.CGridView', array(
'dataProvider' => $model->search() ,
2 1
Viewed: 36 931 times
Version: 1.1
Category: Tips
Written by: clapas
Last updated by: clapas
Created on: Aug 14, 2012
Last updated: 7 years ago
Update Article


View all history