php - CSqlDataProvider sort attributes in CListView -
i have following, $dataprovider in controller:
$sql = 'select * tbl_user order id_user'; $count = 'select count(*) tbl_user'; $dataprovider = new csqldataprovider($sql, array( 'keyfield' => 'id_user', 'totalitemcount' => $count, 'sort' => array( 'attributes' => array( 'name', ), ), 'pagination' => array( 'pagesize' => 15, ), ));
and clistview in view:
$this->widget('zii.widgets.clistview', array( 'dataprovider' => $dataprovider, 'sortableattributes' => array( 'name' => 'name', ), ));
the sort by: name appears when click nothing happens i.e. ajax request works records not sorted. missing? thanks.
i have solved problem with:
$sql = 'select * tbl_user'; $dataprovider = new csqldataprovider($sql, array( 'keyfield' => 'id_user', 'totalitemcount' => $count, 'sort' => array( 'attributes' => array( 'name', ), 'defaultorder' => array('name' => false) ), 'pagination' => array( 'pagesize' => 15, ), ));
the idea remove order within sql statement , let csqldataprovider handle it.
Comments
Post a Comment