How to make CGridView columns sortable (On clicking column title) using CSqldataprovider.
In controller
$sql = "select id ,name, address
from User
where city = 'ABC' ";
$rawData = Yii::app()->db->createCommand($sql);
return $allMovies = new CSqlDataProvider($rawData, array(
'keyField' => 'id',
'sort'=>array(
'attributes'=>array(
'id', 'name', 'address',
),
),
'pagination' => array(
'pageSize' => 10,
),
));
In view
$this->widget('zii.widgets.grid.CGridView', array(
'id' => 'all_movies',
'dataProvider' => $allMoviesStats,
'columns' => array(
'id',
'name',
'address',
'city'
)
)
);?>
It is giving error
"error":{"code":99,"text":"Property \"CGridView.sort\" is not defined.