我有以下代码 DataProvider的:
public function search() {
$criteria = new CDbCriteria;
$criteria->compare('id', $this->id, true);
$criteria->compare('firstname', $this->firstname, true);
$criteria->compare('lastname', $this->lastname, true);
$criteria->compare('email', $this->email, true);
return new CActiveDataProvider($this, array(
'criteria' => $criteria,
'pagination' => array(
'pageSize' => 20
),
'sort' => array(
'defaultOrder' => 'id DESC'
)
));
}
GridView的:
$this->widget('zii.widgets.grid.CGridView', array(
'id'=>'user-grid',
'dataProvider'=>$model->search(),
'columns'=>array(
array('name'=>'id','htmlOptions'=>array( 'width'=>'10%' )),
array('name'=>'email','htmlOptions'=>array( 'width'=>'15%' )),
array('name' => 'firstName', 'htmlOptions'=>array( 'width'=>'10%' ), 'value'=>'$data->firstname'),
array('name' => 'lastName', 'htmlOptions'=>array( 'width'=>'10%' ), 'value' => '$data->lastname'),
),
));
现在,当我查看此网格时,排序适用于Id,电子邮件字段,但不适用于firstName,lastName
有人能告诉我在firsttName和lastName上排序的问题,而它在id和email字段上工作正常吗?