Cgridview Removing The View/edit Buttons & Column Of Widget

Hello,

I am currently trying to use the CGridView (zii.widgets.grid.CGridView) widget in Yii. My data loads fine, but I would like to modify the widget in order to not have the last column which allows for the database entries which populate the table to be viewed/modified.

I am new to Yii, and am inexperienced. Hoping someone understands what I wish to do, and could instruct me on which lines of code to remove/modify. I have attached an image in the hopes of demonstrating what I am trying to do …I would like to remove column 3 completely from my table (including the buttons & their functionality in column 3).

I’m not even sure which file to modify or how :S (up to now, I’ve been modifying the _search.php & admin.php pages in “/protected/views/model”)

Thank you in advance for your help!!!!

Tanya

Dear Friend

In views/model/admin.php, look for the following under columns inside CGridView widget

and remove it.




array(

	'class'=>'CButtonColumn',

		

		),



By default template property of CButtonColumn has following three options.




$template='{view} {update} {delete}';



If we want to allow the users only to view the files, we can modify the column in the following way.




array(

		'class'=>'CButtonColumn',

		'template'=>'{view}'

		),



Regards.

Works great (problem solved)! Thank you!

What if I want to remove the entire column itself…??

Specifying the below code makes the buttons invisible but it doesn’t hide the column.

array(

‘class’=>‘CButtonColumn’,

‘template’ => ‘’,

),

In this case all you need to do is this:

array(

‘class’=>‘CButtonColumn’,

‘visible’=>false,

),