在我的控制器:
$model = new Sheets();
$criteria = new CDbCriteria;
$criteria->compare('id', $model->id);
$criteria->compare('track_name', $model->track_name, true);
$criteria->addCondition('user_id = '.Yii::app()->user->getId().' and '.$listSetups[$i]['condition']);
$setups = new CActiveDataProvider($model, array('criteria' => $criteria));
在我看来:
<?php $this->widget('zii.widgets.grid.CGridView', array(
'id' => 'sheets-grid',
'dataProvider' => $model,
//'filter' => $model,
'template'=>'{items}<div class="nav-controller">{pager}</div>',
'enableSorting' => false,
'columns' => array(
array(
'header' => 'Track',
'name' => 'track_name',
'value' => $model->track_name,
'htmlOptions' => array(
'width' => '135px',
),
),
但是我得到这个错误:
错误:属性“CActiveDataProvider.track_name”没有定义。
任何人都可以告诉我这是为什么? 而如何解决it.And我不想使用$data->track_name
,因为我想在此代码自定义按钮“添加”使用模型- $> TRACK_NAME:
array(
'header' => '',
'class' => 'CButtonColumn',
'template' => '<div class="wrapper-tools">{share}{facebook}{twitter}{download}{add}{update}{delete2}</div>',
'buttons'=>array (
'add' => array
(
'label'=>'Add favorite',
'imageUrl'=> (Users::model()->checkFavorite(Yii::app()->user->getId(), $model->track_name)) ? Yii::app()->themeManager->baseUrl."/default/images/favorite.png" : Yii::app()->themeManager->baseUrl."/default/images/favorite-disabled.png",
'url'=>'Yii::app()->createUrl("/sheets/", array("id"=>$data->id))',
'options' => array('id' => 'add-favorite', 'class' => 'admin-tools' ),
//'visible' => 'Users::model()->checkFavorite(Yii::app()->user->getId(), $data->id) == false',
),
),
'htmlOptions' => array(
'class' => 'admin-tools-2',
),
)
谢谢