Gridview Extra Custom Column With Button

Hello everybody and thanks for reading.

I have a grid view in which i want to add a column with the following code in the value =>


 <a class="pull-right btn btn-info btn-small" target="_blank" id="yw3" href="/test/news/30"><i class="icon-comment"></i> </a>

Or is there a way i could put this code inside a column as a fixed value =>


<?php $this->widget('bootstrap.widgets.TbButton', array(

    'label'=>'Primary',

    'type'=>'primary', // null, 'primary', 'info', 'success', 'warning', 'danger' or 'inverse'

    'size'=>'large', // null, 'large', 'small' or 'mini'

)); ?>

I have tried different approaches but non seem to work , a little tip would be greatly appreciated.

All i want to do is adda button to a column in grid view .

Make sure you’ve set the grid view’s column type to raw or html. You really should provide more information on what you’ve tried and the way in which it’s not working.

sry if i was not clear enough

this is what i have in the columns of the gridview


'columns'=>

            array(

                 array('name'=>'creation_date',

                        'value'=>'Yii::app()->dateFormatter->format("dd MMM yyyy ",$data->creation_date);',  

//                        'filter'=>$this->widget('zii.widgets.jui.CJuiDatepicker',

//                                array(

//                                    'model'=>$model,

//                                    'attribute'=>'creation_date',

//                                    'language' => 'en',

//                                    'i18nScriptFile' => 'jquery.ui.datepicker-en.js',

//                                    'defaultOptions' => array(  

//                                        'dateFormat' => 'yy-mm-dd',

//                           

//                )), true),

                        'htmlOptions'=>array('style'=>'text-align:center;width: 100px'),

              

                ),

		 'title',	

                array(

                    'name'=>'summary',

                    'type'  => 'raw',

                    ),

                 array(

                    'class'=>'CLinkColumn',

                    //'header'=>Yii::t('ui','id_project'),

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

                    'labelExpression'=>'$data->id_news',

                    'urlExpression'=>'Yii::app()->request->baseUrl."/news/view/".$data->id_news',

                   // 'urlExpression'=>'"../../uploads//".$data->file_name',

                    'htmlOptions'=>array('style'=>'text-align:center;width: 50px'),

                ), 

instead of the CLinkColumn i want to place a button with the code from my first post.

What iam trying to do is put a button or link as a fixed value , the button is just a link to the details of that row.

Something like this?




array(

    'header'=>'',

    'type'=>'html',

    'value'=>function($data){

        return CHtml::link('<i class="icon-comment"></i>',

                array('/test/news/30'),

                array(

                    'id'=>'yw3'

                    'class'=>'pull-right btn btn-info btn-small',

                    'target'=>'_blank',

                ));

    },

),



I’m not sure how you’re generating your link, but you can use the attributes in $data to generate it dynamically. Just change array(’/test/news/30’) to an appropriate array.

Nice , i think this is it , iam getting a syntax error in your code but you put me on the right tracks now i know what to search for , if you find the error plz let me know thanks for everything

There’s a missing comma after the id attribute.

True, thanks , clumsy me … and yhea did i say thanks