我需要一种通过单击列标题对网格进行排序的方法...
public function search() {
$criteria = new CDbCriteria;
$criteria->select = 'cac.id, cac.client_name, cac.phone, cd.code, t.outgoing_call_date, (SELECT count(id) FROM css_ataps_calls WHERE caller_id = cac.id AND start_date = current_date) as attempts;
分拣部分
$sort = new CSort();
$sort->defaultOrder = 'cac.id';
$sort->attributes = array('client_id', 'attempts'=>array('asc'=>'attempts', 'desc'=>'attempts DESC'));
SGridView 代码
array('name'=>'attempts',
'type'=>'raw',
'value'=>'$data->attempts',
'htmlOptions'=>array('style'=>'width:15%;text-align:center;'),
'headerHtmlOptions'=>array('style'=>'width:15%;')
),