如何自定义BsGridView以显示链接而不是BsButtonColumn?

时间:2014-06-04 18:01:37

标签: php twitter-bootstrap yii-extensions

根据以下代码,我需要自定义第三个列,以显示两个链接而不是BsButtonColumn。我没有找到任何相关的文档来得到答案。

<?php
    $this->widget(
        'bootstrap.widgets.BsGridView',
        array(
            'id' => 'activity-translation-grid',
            'dataProvider' => $model->search(),
            'filter' => $model,
            'columns' => array(
                'id',
                'name',
                array(
                    'class' => 'BsButtonColumn',
                ),
            ),
        )
    );
?>

2 个答案:

答案 0 :(得分:1)

可能是这样的:

$this->widget(
    'bootstrap.widgets.BsGridView',
    array(
        'id' => 'activity-translation-grid',
        'dataProvider' => $model->search(),
        'filter' => $model,
        'columns' => array(
            'id',
            'name',
            array(
                'class' => 'bootstrap.widgets.BsButtonColumn',
                'template' => '{en} {es} {it}',
                'buttons' => array(
                    'en' => array(
                        'label' => 'EN',
                        'url' => '"translate/en/" . $data->id',
                        'visible' => '1',
                    ),
                    'es' => array(
                        'label' => 'ES',
                        'url' => '"translate/en/" . $data->id',
                        'visible' => '1',
                    ),
                    'it' => array(
                        'label' => 'IT',
                        'url' => '"translate/it/" . $data->id',
                        'visible' => '1',
                    ),
                ),
            ),
        ),
    )
);

答案 1 :(得分:0)

$this->widget(
    'bootstrap.widgets.BsGridView',
    array(
        'id' => 'activity-translation-grid',
        'dataProvider' => $model->search(),
        'filter' => $model,
        'columns' => array(
            'id',
            'name',
            array(
                'class' => 'CLinkColumn',
                'urlExpression' => '"translate/en/" . $data->id',
            ),
            array(
                'class' => 'CLinkColumn',
                'urlExpression' => '"translate/es/" . $data->id',
            ),
            array(
                'class' => 'CLinkColumn',
                'urlExpression' => '"translate/it/" . $data->id',
            ),
        ),
    )
);