这是我的代码
$this->widget('zii.widgets.grid.CGridView', array(
'id'=>'dsfsd',
'dataProvider' => $model->search(),
'filter' => $model,
'cssFile' => false,
'itemsCssClass' => 'table table-striped',
'beforeAjaxUpdate'=>'js:function(id,options){$.blockUI({
message: "Please wait",
//showOverlay: false,
css: {
border: "none",
padding: "15px",
"-webkit-border-radius": "10px",
"-moz-border-radius": "10px",
opacity: 1,
"z-index": "9999"
}
});}',
'columns' => array(
array(
'header' => '#',
'name' => 'id',
'type' => 'raw',
'value' => 'CHtml::link(CHtml::encode($data->id),array("abc/m/".CHtml::encode($data->id)."/info"))',
'htmlOptions' => array('width' => '40px'),
'filter' => CHtml::activeTextField($model, 'id', array('placeholder' => 'search by id')),
), array(
'header' => 'First name',
'name' => '$data.user.f_name',
'type' => 'raw',
'value' => 'CHtml::encode($data->user->f_name)',
), array(
'header' => 'Last name',
'name' => '$data.user.l_name',
'type' => 'raw',
'value' => 'CHtml::encode($data->user->l_name)'
),
array(
'class' => 'CButtonColumn',
'template' => '{update} {delete}',
//'updateButtonUrl' => 'Yii::app()->createUrl("abc/xyz?id=".$data->id."&c_id=".$data->c_id)',
'deleteButtonUrl' => 'Yii::app()->createUrl("xyv/abc",array("uid"=>$data->id))',
),
),
));
嗯,我想要的是,beforeAjaxUpdate下的操作只有在点击删除按钮时才有效,而不适用于搜索或更新等任何其他ajax操作。怎么可能?
答案 0 :(得分:0)
您可以添加回拨功能以删除按钮: http://www.yiiframework.com/doc/api/1.1/CButtonColumn#buttons-detail
您应该在按钮config array中设置click
选项:
'columns' => array(
...
'buttons'=>array(
'class'=>'CButtonColumn',
'template'=>'{delete}{update}',
'buttons'=>array(
'delete'=>array(
'click'=>'function(){/*your code here*/}'
)
)
)
...
)
您可以从回调函数返回false
以防止删除。