Yii Framework Forum: No Pagination in CGridView - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

No Pagination in CGridView Rate Topic: -----

#1 User is offline   Daniel 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 218
  • Joined: 26-September 09

Posted 25 January 2012 - 03:28 AM

Dear All,

I have no success in setting no pagination in CGridView. What I do:

1. Add this portion of code in the controller
         $details = new CActiveDataProvider('SalesDetail', array(
                    'criteria' => array(
                        'condition' => 'salesFk = :sFk',
                        'params' => array(':sFk' => $model->id),
                        ),
                     'pagination' => false));


2. Add 'enablePagination' to 'false' in CGridView.

step 2 no problem, no pagination portion of the CGridView. Hoever, I got problem on step 1. Error because I set to false.

Any help on this?

Cheers,

Daniel
0

#2 User is offline   angela88 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 144
  • Joined: 14-October 11
  • Location:Jakarta

Posted 25 January 2012 - 04:23 AM

i'm not sure but i think it's because the value of pagination is not a boolean but object.

u can use template in your gridview
'template'=>'{items}',

with this code you just show your table/gridview without paging and summarytext.

sorry for my bad english.
0

#3 User is offline   Daniel 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 218
  • Joined: 26-September 09

Posted 26 January 2012 - 03:23 AM

with enablePagination = false, it would not display the pagination, but the data is only shown as defined on the CAvticeDataProvider. It used to be worked fine in Yii 1.0.x. But now, in Yii 1.1.x, I cannot to make it work....

Thanks for your answer.
0

#4 User is offline   Maurizio Domba Cerin 

  • Yii - Yesss It Is !!!
  • Yii
  • Group: Yii Dev Team
  • Posts: 4,342
  • Joined: 12-October 09
  • Location:Croatia

Posted 26 January 2012 - 04:25 AM

The 'pagination' => false in CActiveDataProvider without the enablePagination option works for the CGridView (just tested to be sure)...
Find more about me.... btw. Do you know your WAN IP?
0

#5 User is offline   Daniel 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 218
  • Joined: 26-September 09

Posted 05 February 2012 - 11:34 PM

Hi mdomba,

I got "Trying to get property of non-object" when doing this without enablePagination

$periodes = new CActiveDataProvider('Periode', array(
                    'criteria' => array(
                        'condition' => 'academicYearFk = :year',
                        'params' => array(':year' => $model->id),
                        'order' => 'shortName ASC',
                    ),
                    'pagination' => false,
                ));


Something wrong with my code?
1

#6 User is offline   Maurizio Domba Cerin 

  • Yii - Yesss It Is !!!
  • Yii
  • Group: Yii Dev Team
  • Posts: 4,342
  • Joined: 12-October 09
  • Location:Croatia

Posted 06 February 2012 - 03:28 AM

It would help if you would check the stack trace... and find which object does generate this error...

for example in the above code this error can happen on $model->id if the variable $model is not an object...
Find more about me.... btw. Do you know your WAN IP?
0

#7 User is offline   Daniel 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 218
  • Joined: 26-September 09

Posted 06 February 2012 - 07:44 AM

Hi mdomba,

Below is the stack trace

Trying to get property of non-object
(C:\xampp-yski\xampp\framework\base\CComponent.php(619) : eval()'d code:1)
Stack trace:
#0 C:\xampp-yski\xampp\framework\zii\widgets\grid\CGridColumn.php(135):
BootDataColumn->renderDataCellContent()
#1 C:\xampp-yski\xampp\framework\zii\widgets\grid\CGridView.php(512):
BootDataColumn->renderDataCell()
#2 C:\xampp-yski\xampp\framework\zii\widgets\grid\CGridView.php(485):
BootGridView->renderTableRow()
#3 C:\xampp-yski\xampp\framework\zii\widgets\grid\CGridView.php(395):
BootGridView->renderTableBody()
#4 C:\xampp-yski\xampp\framework\zii\widgets\CBaseListView.php(158):
BootGridView->renderItems()
#5 unknown(0): BootGridView->renderSection()
#6 C:\xampp-yski\xampp\framework\zii\widgets\CBaseListView.php(141):
preg_replace_callback()
#7 C:\xampp-yski\xampp\framework\zii\widgets\CBaseListView.php(126):
BootGridView->renderContent()
#8 C:\xampp-yski\xampp\framework\web\CBaseController.php(166):
BootGridView->run()
#9
C:\xampp-yski\xampp\htdocs\yski_fee\protected\views\academicYear\view.php(77):
AcademicYearController->widget()
#10 C:\xampp-yski\xampp\framework\web\CBaseController.php(119): require()
#11 C:\xampp-yski\xampp\framework\web\CBaseController.php(88):
AcademicYearController->renderInternal()
#12 C:\xampp-yski\xampp\framework\web\CController.php(866):
AcademicYearController->renderFile()
#13 C:\xampp-yski\xampp\framework\web\CController.php(779):
AcademicYearController->renderPartial()
#14
C:\xampp-yski\xampp\htdocs\yski_fee\protected\controllers\AcademicYearController.php(40):
AcademicYearController->render()
#15 unknown(0): AcademicYearController->actionView()
#16 C:\xampp-yski\xampp\framework\web\actions\CAction.php(104):
ReflectionMethod->invokeArgs()
#17 C:\xampp-yski\xampp\framework\web\actions\CInlineAction.php(48):
CInlineAction->runWithParamsInternal()
#18 C:\xampp-yski\xampp\framework\web\CController.php(300):
CInlineAction->runWithParams()
#19 C:\xampp-yski\xampp\framework\web\filters\CFilterChain.php(134):
AcademicYearController->runAction()
#20 C:\xampp-yski\xampp\framework\web\filters\CFilter.php(41):
CFilterChain->run()
#21
C:\xampp-yski\xampp\htdocs\yski_fee\protected\modules\rights\components\RController.php(36):
RightsFilter->filter()
#22 C:\xampp-yski\xampp\framework\web\filters\CInlineFilter.php(59):
AcademicYearController->filterRights()
#23 C:\xampp-yski\xampp\framework\web\filters\CFilterChain.php(131):
CInlineFilter->filter()
#24 C:\xampp-yski\xampp\framework\web\CController.php(283):
CFilterChain->run()
#25 C:\xampp-yski\xampp\framework\web\CController.php(257):
AcademicYearController->runActionWithFilters()
#26 C:\xampp-yski\xampp\framework\web\CWebApplication.php(277):
AcademicYearController->run()
#27 C:\xampp-yski\xampp\framework\web\CWebApplication.php(136):
CWebApplication->runController()
#28 C:\xampp-yski\xampp\framework\base\CApplication.php(158):
CWebApplication->processRequest()
#29 C:\xampp-yski\xampp\htdocs\yski_fee\index.php(13):
CWebApplication->run()
REQUEST_URI=/yski_fee/academicYear/6


The thing is if I change the code to
$periodes = new CActiveDataProvider('Periode', array(
                    'criteria' => array(
                        'condition' => 'academicYearFk = :year',
                        'params' => array(':year' => $model->id),
                        'order' => 'shortName ASC',
                    ),
                    'pagination' => array(
                        'pageSize' => 20,
                    )
                ));


It will work just fine. It gives me a lot of headache.......
0

#8 User is offline   Maurizio Domba Cerin 

  • Yii - Yesss It Is !!!
  • Yii
  • Group: Yii Dev Team
  • Posts: 4,342
  • Joined: 12-October 09
  • Location:Croatia

Posted 06 February 2012 - 08:14 AM

From the error stack you can see that the error comes from renderdataCellContent() so the problem is with some column value...

one of your columns maybe has a relation value (like $post->author->name)... and on that record that fires the error... the relation does not have a value ($post->author is null)...

It works for you when you set 20 records... because the "error" record is somewhere after that... to check this try with a bigger number until you find the one that fires the error...
Find more about me.... btw. Do you know your WAN IP?
0

#9 User is offline   Daniel 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 218
  • Joined: 26-September 09

Posted 06 February 2012 - 01:49 PM

The result is only 14 rows, that's why I set pagination to 20 to make all rows appear.

FYI, each academicYear will always has 14 periode.
0

#10 User is offline   Maurizio Domba Cerin 

  • Yii - Yesss It Is !!!
  • Yii
  • Group: Yii Dev Team
  • Posts: 4,342
  • Joined: 12-October 09
  • Location:Croatia

Posted 06 February 2012 - 02:53 PM

I can't help you more here...

My suggestion is to create a default CRUD with Gii and then set the pagination false... just so to see if it works... and then search/debug to find what is wrong with your code...
Find more about me.... btw. Do you know your WAN IP?
0

#11 User is offline   apinx 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 5
  • Joined: 16-March 12

Posted 06 January 2013 - 09:11 PM

Help me, sir.

I have 45 data and I sort 23 data.
With pageSize 10.

My problems,
The pagination have 5 page, not 3 pages.

Have you this solve?

thanx, sir.
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users