添加确认删除bootstrap.widgets.TbGridView

时间:2013-11-07 11:27:42

标签: yii

我想添加确认删除,怎么做?

'delete'=>array(
            'class'=>'\ext\crud\actions\DeleteAction',
            'modelName'=>'ManagerCategory',
            array('confirm' => 'Are you sure?'),
            'definedAttributes'=>array(
                'id'=>r()->getQuery('id'),
                'store'=>$this->module->getStoreId(),
            )
        )

谢谢!

2 个答案:

答案 0 :(得分:2)

这实际上取决于你是如何做到这一点的。以下是使用我经常使用的CHtml按钮的确认方法的示例。

<?php echo CHtml::submitButton('Cancel', array('name'=>'cancel', 'class'=>'button alert large submit','confirm'=>'Are you sure you want to cancel the whole order?')); ?>

答案 1 :(得分:0)

所以,正确答案是

'delete'=>array(
                    'htmlOptions' => array(
                        'onclick'=>'return confirm("Are you sure?")',
                    ),
                ),

谢谢!

P.S。

'list'=>array(
            'class'=>'\ext\crud\actions\ListAction',
            'modelName'=>'ManagerCategory',
            'title'=>'Manage categories',
            'definedAttributes'=>array(
                'store'=>$this->module->getStoreId(),
            ),
            'columns'=>array(
                'id',
                'title',
                'parent'=>array(
                    'name'=>'Parent',
                    'type'=>'raw',
                    'value'=>'$data->parent?$data->parent0->title:""'
                ),
                'delete'=>array(
                    'htmlOptions' => array(
                        'onclick'=>'return confirm("Are you sure?")',
                    ),
                ),
            )
        ),