【发布时间】:2013-12-09 06:40:35
【问题描述】:
在一个基于 YII 的项目中,我有一个 cgridview。要求是使整行或每列值成为链接,然后单击行中的任何链接将触发 ajax 调用。我从这里尝试过
How to display rows of CGridView as a link
但如果我将整行设置为可点击,则需要我查看操作。
如果我将一行中的单个列值作为链接并调用 ajax 函数,我会收到以下错误。
Property "CDataColumn.options" is not defined.
我需要帮助将整行设为可点击并调用 ajax 函数或单个行值以在点击时调用 ajax 函数。
非常感谢任何正确方向的帮助或指导。
//code for making trading name column in cgridview as clickable and call ajax
<?php $this->widget('zii.widgets.grid.CGridView', array(
'id'=>'customer-grid',
'dataProvider'=>$model->search(),
'filter'=>$model,
'columns'=>array(
'id',
array(
'name' => 'trading_name',
'value' => 'CHtml::link($data->trading_name, Yii::app()
->createUrl("customer/view/",array("id"=>$data->primaryKey)))',
'type' => 'raw',
'options' => array('ajax' => array('type' => 'get', 'url'=>'js:$(this).attr("href")',
'success' => 'js:function(data) {
$("#tab1").html(data);')
),
),
'email',
'site_code',
array(
'class'=>'CButtonColumn',
),
【问题讨论】: