1. Christoffer Niska
  2. yii-bootstrap
  3. Issues
Issue #242 new

How to add button in bootstrap.widgets.TbGridView column as a column value

mamunur Hosse
created an issue

Dear,

I am new Yii and not so expert in widget. Please help me to add drop down button in any column using 'value' => {widget to add dropdown}. I am giving the code to make you clear.

$this->widget('bootstrap.widgets.TbGridView', array(
    'id'=>'followups-grid',
    'dataProvider'=>$model->search(),
    'rowCssClassExpression' => '\'ticket-followup-\'.$data->ID',
    //'filter'=>$model,
    'columns'=>array( 
        array(
            'name' => 'FOLLOWUP_MESSAGE',
            'value'=>   '"<div class=\"summery\">". split_words(CHtml::decode($data->FOLLOWUP_MESSAGE), 10). "</div>"
                            ."<div class=\"details hide\">".  CHtml::decode($data->FOLLOWUP_MESSAGE) . "</div>" 
                        ',

            'type' => 'html',
            'header'=>false,
            'filter'=>false,
            'htmlOptions'=>array('width'=>'90%', "id" => $model->ID, 'class'=>'followup-row content-area',),
        ),

        //'INTERNAL_MESSAGE',

        array(
            'name'          =>  'ENTRY_TIME', 
            'value' => 'btnWidget()',

            'type'          =>  'html',
            'header'        =>  false,
            'filter'        =>  false,
            'htmlOptions'   =>  array('width'=>'10%', "id" => '$row+1', 'class'=>'followup-row ',),

        ),

    ),
)); 

function btnWidget(){

    $widget = new CWidget();
    return $widget->widget('bootstrap.widgets.TbButtonGroup', array(
        'type'=>'info', // '', 'primary', 'info', 'success', 'warning', 'danger' or 'inverse'
        'buttons'=>array(
            array('label'=>'Action', 'url'=>'#'),
            array('items'=>array(
                array('label'=>'Action', 'url'=>'#'),
                array('label'=>'Another action', 'url'=>'#'),
                array('label'=>'Something else', 'url'=>'#'),
                '---',
                array('label'=>'Separate link', 'url'=>'#'),
            )),
        ),
    ), true) ;

}

By this code a grid view is populated with a button but the button is not the dropdown able. After analyzing I found that the code is missing the data-toggle="dropdown". I test that inspecting code using chrome and applying the code.

Please help me. I am stacked by this point.

Comments (0)

  1. Log in to comment