Pagination for CSqlDataProvider through CGridView

I wanna display the data through CGridView and where the dataprovider is CSqlDataProvider and with pagination…

I have code like this as shown below.


$dataProviderRegSum = new CSqlDataProvider($rawData, array(

	   		 'keyField' => 'familyid',

	   	 	'totalItemCount' => $count,

	   		 'pagination'=>array('pageSize'=>20),

	   	  

	   		 'sort'=>array(

	   			  	'defaultOrder' => 'PaymentTxnDate asc',

	   				 'attributes'=>array(

	   						 'RegistrationID'=>array(

	   								 'asc'=>'familyid',

	   								 'desc'=>'familyid DESC',

	   						 ),

	   						 'FirstName'=>array(

	   								 'asc'=>'firstname',

	   								 'desc'=>'firstname DESC',

	   						 ),

	   						 'LastName'=>array(

	   								 'asc'=>'lastname',

	   								 'desc'=>'lastname DESC',

	   						 ),

	   						 'CreatedDate'=>array(

	   								 'asc'=>'CreatedDate',

	   								 'desc'=>'CreatedDate DESC',

	   						 ),

	   						 'EmailedDate'=>array(

	   								 'asc'=>'EamiledDate',

	   								 'desc'=>'EamiledDate DESC',

	   						 ),





	   				 ),),

and for this it is showing 20 records but not showing the hyperlinks for pagination…thank you so much …please help me…

First the code you have post it look like Yii 1 Code but you are on Yii 2 section.

Second can you show the CGriedView Code but plz in the Yii 1 Section.

[color="#006400"]/* Moved from "2.0 - General Discussions" to "1.1.x - General Discussions" */[/color]

Sorry I dont know about yii 1.1 or 2.0 …and my gridview looks like as shown


 $this->widget('zii.widgets.grid.CGridView', array(

			'id'=>'family-record-grid',

			'dataProvider'=>$arr[1],

			'enableSorting' => false,

			

			//'enablePagination'=>false,

			 

			'itemsCssClass'=>'tabchin',

			

			'columns'=>

			array(),

));

i have pagesize=20

and totalItemCount but

the result is showing first 20 records and didnt show the hyperlinks i.e. pagenumbers for pagination…why …please

Hi CRajesh,

was is $arr[1] ?

It think it the code muss look like this.




 $this->widget('zii.widgets.grid.CGridView', array(

                        'id'=>'family-record-grid',

                        'dataProvider'=> $dataProviderRegSum,

                        'enableSorting' => false,

                        'itemsCssClass'=>'tabchin',

));



Hi ,yes the dataprovider is


$dataProviderRegSum 

but then also I didnt get pagination …

shows 20 records on first page and hyperlinks for the paging

but when i click on the pagenumber 2 ,the first page will be showing .

…whatever the pagenumber you click will goes to the first page with 20 records…

i also tested the query for any syntanctical errors but i didnt find any…

I dnt know what to do stuck for one week on same problemmmmmmm…

i have found this thread maybe it can help you http://www.yiiframework.com/wiki/639/csqldataprovider-in-cgridview/.

Thank you for reply…I had search all the stuff in the net after that I have posted it in this forum…

And I have found the problem …

that I have a search popup in the page so every time refreshing the page for pagination the search popup is displayed …

thank you for response…