In the search function of your model, where customField is the name of your field:// ...other criteria...$criteria->compare('customField',$this->customField);$sort = new CSort();$sort->attributes = array( 'customField'=>array( 'asc'=>'customField ASC', 'desc'=>'customField DESC', ), '*', // this adds all of the other columns as sortable);return new CActiveDataProvider($this, array( 'criteria'=>$criteria, 'sort'=>$sort,));您可能还需要更新模型中的 rules 和 attributeLabels 以反映新的自定义字段.You may also need to update rules and attributeLabels in your model to reflect the new custom field. 这篇关于CGridview 自定义字段可排序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云!
08-14 10:12