Create New Item Functionality For Cgridview

Hi there!

I know how to add additional buttons to CButtonColumn and set properties of those but I’m trying to achieve something different here.

I would like to have one ‘Create new item’ option for my CGridView next to the filter options as shown on the attached screen.

Anybody has any idea how to achieve this?

Thanks in advance,

g0m3z

hi inside CGridView u can write like this…

suppose u want to add a button to change password…





 array(            // display a column with "view", "update" and "delete" buttons

            'class'=>'CButtonColumn',

			'template'=>'{view}{update}{change_password}',

			'buttons'=>array

					(

						'change_password' => array

						(

							'label'=>'Change password of this user',

							'imageUrl'=>Yii::app()->theme->baseUrl.'/images/some_image.png',

							'url'=>'Yii::app()->createUrl("your/change_password/view/url/here", array("id"=>$data->some_id))',

						),						

					),

        ),

    ),	



try this

Hi,

I hope this link will give you some path to implement this…

http://www.yiiframework.com/extension/clear-filters-gridview/

If its useful post your solution and upvote to indicate for positive result :)

@mannu

Thanks, but as I mentioned I already know how to extend CButtonColumn with additional buttons.

What I’m looking for is one single button on the top of my grid view (please check the enclosed image in my first post).

Your solution shows the additional custom button only if you have some data in your grid. I would like to be able to add new record to my model from grid view even if it is empty.

The reason why I need this is that I would like to change Yii’s default 2 columns view and would like to eliminate the right-hand side menu bar to extend my grid full-screen. My client prefer to use grid view instead of menu options.

If anybody knows an extension grid view with advanced features that would be also fine.

Thanks,

g0m3z

@chandran

Thanks, but I can’t really figure out how to adopt this to my case. I’m quite new to Yii.