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

Popular posts from this blog

OpenCV OpenCL: Convert Mat to Bitmap in JNI Layer for Android -

android - org.xmlpull.v1.XmlPullParserException: expected: START_TAG {http://schemas.xmlsoap.org/soap/envelope/}Envelope -

python - How to remove the Xframe Options header in django? -