0
我在我的代碼中有兩個問題: 1)當您點擊它時,您無法通過標題「標題」進行排序。 2)你可以點擊標題,認爲這將按字母順序排序,箭頭出現,但沒有任何反應,沒有排序。 CGridView列中的鏈接
網站/ index.php文件
$this->widget('zii.widgets.grid.CGridView', array(
'dataProvider' => $dataProvider,
'columns' => array(
'title' => array(
'class'=>'CLinkColumn',
'labelExpression' => '$data->title',
'urlExpression'=>'Yii::app()->request->baseUrl."/page/".$data->id',
'header'=>'Title',
'headerHtmlOptions' => array('style'=>'width:250px;'),
),
'created' => array(
'name' => 'created',
'value' => 'date("j.m.Y H:i", $data->created)',
'headerHtmlOptions' => array('style'=>'width:90px;'),
),
'category_id' => array(
'name' => 'category_id',
'value' => '$data->category->title',
'filter' => Category::allCategory(),
'headerHtmlOptions' => array('style'=>'width:150px; text-align:center;'),
),
'subcategory_id' => array(
'name' => 'subcategory_id',
'value' => '$data->subcategory->title',
'filter' => Subcategory::allCategory(),
'headerHtmlOptions' => array('style'=>'width:150px; text-align: center;'),
),
'condition_id' => array(
'name' => 'condition_id',
'value'=> '$data->condition->title',
'filter' => Condition::allAttributes(),
'headerHtmlOptions' => array('style'=>'width:90px;'),
),
),
));
SiteController
public function actionIndex()
{
$dataProvider=new CActiveDataProvider('Page', array(
'criteria'=>array(
'order'=>'id DESC',
),
'pagination'=>array(
'pageSize'=>30,
),
));
// renders the view file 'protected/views/site/index.php'
// using the default layout 'protected/views/layouts/main.php'
$this->render('index', array('dataProvider'=>$dataProvider));
}
該控制器還沒有模型。
Manquer,沒有任何反應! –
'排序'=>數組( '屬性'=>數組( '標題', '創造', 'CATEGORY_ID', 'subcategory_id', 'condition_id', ), –
標題 「標題」不會顯示爲鏈接而不是文本,並且必須是鏈接 –