Yii CGridView 定制bottons方法

示例代码

array(
   'class'=>'CButtonColumn',
    'template'=>'{email}{view}{update}{delete}',
    'buttons'=>array(
        'email' => array(
            'label'=>'email',
            'imageUrl'=>Yii::app()->request->baseUrl.'/images/icon_sina.gif',
            'url'=>'Yii::app()->createUrl("users/email", array("id"=>$data->id))',
        ),          
    ),
),

其中本人做的一个例子

<?php $this->widget('zii.widgets.grid.CGridView', array(
    'dataProvider'=>$model->search(),
    'columns'=>array(   
        array(
            'selectableRows' => 2,
            'footer' => '<button type="button" onclick="GetCheckbox();" style="width:76px">批量删除</button>',
            'class' => 'CCheckBoxColumn',
            'headerHtmlOptions' => array('width'=>'33px'),
            'checkBoxHtmlOptions' => array('name' => 'selectdelete[]'),
        ),
        'company'=>array(
            'name'=>'company',
            'value'=>'$data->company',
            'footer' => '<button type="button" onclick="GetTopBox();" style="width:76px">批量推荐</button>',
        ),          // display the 'title' attribute
        'model'=>array(
            'name'=>'model',
            'value'=>'$data->model',
            'footer' => '<button type="button" onclick="GetUnBox();" style="width:76px">取消推荐</button>',
        ),
        'top'=>array(
            'name'=>'top',
            'value'=>'$data->tops'
            ),
        'category',
        'brand',
        'money',
        'number',
        'status'=>array('name'=>'status','value'=>'$data->getstatus'),
        array(            // display a column with "view", "update" and "delete" buttons
            'class'=>'CButtonColumn',
        ),
    ),
));
?>

发表评论