php - CGridView Pagination not working. Yii -
i have form in view selects columns dropdown list. sqldataprovider used data generated query
i have been trying use cgridview sqldataprovider, working bit fine, still having issues pagination. don't have keyfield give first column, , without keyfield doesn't work.
here action:
public function actionindex() { $tables = yii::app()->db->schema->gettables(); if(isset($_post['yt0'])){ //if submitted $query = $this->generatequery(); $count=yii::app()->db->createcommand('select count(*) ( ' . $query . ' ) count')->queryscalar(); $dataprovider = new csqldataprovider($query, array( 'keyfield' => $firstcolumn, 'totalitemcount'=> $count, 'pagination'=> array( 'pagesize'=>20, ), )); $columns = $this->getcolumnnameswithouttable(); $this->render('index', array( 'tables' => $tables, 'query' => $query, 'dataprovider' => $dataprovider, 'columns' => $columns ) ); }else{ $this->render('index', array('tables' => $tables)); } }
here widget code in view, according have read, pagination should work automatically, because using custom query rather yii models ?
$this->widget('zii.widgets.grid.cgridview', array( 'dataprovider'=>$dataprovider, 'enablepagination'=> true, ));
it shows data first time, next button doesn't work.
'keyfield' => $firstcolumn
what $firstcolumn value.
keyfield must index of array retiring csqldataprovider
Comments
Post a Comment