Click here for EduSec Demo EduSec Screenshots

create custom gridview using csqldataprovider.

On 2013-06-10 - By Ravi Thanki

CSqlDataProvider implements a data provider based on a plain SQL statement. CSqlDataProvider provides data in terms of arrays, each representing a row of query result. Like other data providers, CSqlDataProvider also supports sorting and pagination. It does so by modifying the given sql statement with "ORDER BY" and "LIMIT" clauses. You may configure the sort and pagination properties to customize sorting and pagination behaviors.

i have create one action in my controller.

public function actionMyadmin()
{
$sql=’SELECT * FROM user’;
$dataProvider=new CSqlDataProvider($sql);
$this->render(‘myadmin’,array(
‘dataProvider’=>$dataProvider,
));
}

In my view file

widget(‘zii.widgets.grid.CGridView’, array(
‘id’=>’student-grid’,
‘dataProvider’=>$dataProvider,
‘columns’=>array(
‘id’,
‘user_id’,
‘password’,

),
)); ?>