我需要在管理面板或管理页面中按ASC
和DESC
顺序按特定字段进行排序。
SORT_ORDER
字段是排序。我尝试actionindex()
进行排序但没有工作,并且调用actionadmin()
无法正常工作,但请致电actionadmin()
http://localhost/mate/admin/admin/index.php?r=sdmattsFurniture/admin
以上是我的网址。
控制器:
public function actionIndex()
{
$dataProvider=new CActiveDataProvider('SdmattsFurniture');
$this->render('index',array(
'dataProvider'=>$dataProvider,
));
}
public function actionAdmin()
{
$model=new SdmattsFurniture('search');
$model->unsetAttributes(); // clear any default values
if(isset($_GET['SdmattsFurniture']))
$model->attributes=$_GET['SdmattsFurniture'];
$this->render('admin',array(
'model'=>$model,
));
}
GRIDVIEW:
$this->widget('zii.widgets.grid.CGridView', array(
'id'=>'sdmatts-furniture-grid',
'dataProvider'=>$dataProvider,
/*'filter'=>$model,*/
'columns'=>array(
'furniture_id',
'furniture_name',
'furniture_code',
'furniture_dimension',
'sort_order',
array(
'name'=>'furniture_cost',
'value' => function($data) {
return round($data->furniture_cost, 0, 100);
},
),
array(
'name'=>'furniture_image',
'type' => 'raw',
'value' =>'CHtml::image(Yii::app()->baseUrl."../../uploads/".$data->furniture_image,"",array("width"=>120,"height"=>120))',
),
array(
'class'=>'CButtonColumn',
),
),
));
答案 0 :(得分:0)
你的问题不是很明确,也许在代码下面你需要的东西:)
public function actionIndex()
{
$dataProvider=new CActiveDataProvider('SdmattsFurniture');
$dataProvider->criteria->order = 'sort_order asc';
$this->render('index',array(
'dataProvider'=>$dataProvider,
));
}
public function actionAdmin()
{
$model=new SdmattsFurniture('search');
$model->unsetAttributes(); // clear any default values
if(isset($_GET['SdmattsFurniture']))
$model->attributes=$_GET['SdmattsFurniture'];
$model->dbCriteria->order = 'sort_order asc';
$this->render('admin',array(
'model'=>$model,
));
}