Yii: 如何把JS脚本添加到CGridView数据行的操作按钮中

可以简单的添加到按钮的url属性中,把链接改为js, 然后在js中调用相关的ajax请求,示范如下

        array(
          'class'=>'FButtonColumn',
            'header'=>Yii::t('Trade','Actions'),
          'template'=>'$data->getTemplate()',
          'buttons'=>array(
                'reject'=>array(
                    'label'=>Yii::t('Trade','Reject'),
                    'imageUrl'=>Yii::app()->theme->BaseUrl.'/images/refuse.png',
                    'url'=> '"javascript:oops(\"".$data->id."\");"',
                ),
                'update'=>array(
                    'label'=>Yii::t('Trade','Edit'),
                    'url'=>'Yii::app()->controller->createUrl("edit", array("Id"=>$data->primaryKey))',
                ),                              
             ),
          'htmlOptions'=>array('class'=>'alignLeft','style'=>'width:25%;'),
        )

by iefreer

你可能感兴趣的:(PHP,yii)