yhl27ml@163.com 2011-11-02 17:46:21 2847次浏览 1条回复 0 0 0

我想控制CButtonColumn里的deleteButton显示与否,例如:

array(
    'class' => 'CButtonColumn',
    'template' => '{authId} {delete}',
    'afterDelete' => 'function(link,success,data){ if(data) {alert(data);} }',
    'buttons' => array(
        'authId' => array(
            'label' => '编辑权限',
            'url' => 'Yii::app()->createUrl("auth/rightsManageme/distributionRights",                      
            array("id"=>$data->primaryKey))',
            'visible' => '$data->name != Yii::app()->params["adminRole"]',
            'imageUrl' => Yii::app()->baseUrl."/images/share/icon_edit.gif",
        ),
    ),
),

相当于其他按钮的visible属性的运用,我自定义的按钮里面可以用‘visible’来控制此按钮是否显示,但是,在此组件自带的‘delete’按钮该怎么控制它的显示与否呢?

  • 回复于 2011-11-02 17:52 举报

    呵呵,刚提交问题就马上想到了怎么解决了,不好意思。
    就是重新写下‘delete’的visibel属性。。例如:

    array(
        'class' => 'CButtonColumn',
        'template' => '{authId} {delete}',
        'afterDelete' => 'function(link,success,data){ if(data) {alert(data);} }',
        'buttons' => array(
            'authId' => array(
                'label' => '编辑权限',
                'url' => 'Yii::app()->createUrl("auth/rightsManagemen/distributionRights",                 
                array("id"=>$data->primaryKey))',
                'visible' => '$data->name != Yii::app()->params["adminRole"]',
                'imageUrl' => Yii::app()->baseUrl."/images/share/icon_edit.gif",
            ),
            'delete' => array(
                'visible' => '$data->name != Yii::app()->params["adminRole"]',
            ),
        ),
    ),
    
    
您需要登录后才可以回复。登录 | 立即注册