madcorp / zfdatagrid

Automatically exported from code.google.com/p/zfdatagrid
BSD 3-Clause "New" or "Revised" License
0 stars 0 forks source link

$grid->setRecordsPerPage does not work if grid.recordsPerPage is set in config #837

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. create a grid, use grid.recordsPerPage = 10 in config
2. use $grid->setRecordsPerPage(0); to show all entries

What is the expected output? What do you see instead?
expected: the grid will show all entries
actual; the grid will only show 10 entries

Please insert the appropriate values;
                    Zend Framework version: 1.11.11
ZFDatgrid Version (Bvb_Grid::getVersion()): 0.8
                          Operating system: Linux
                               PHP Version: 5.3.6
               Database Server and version: MySQL 5.1

Please provide any additional information below.

Grid.php, line 3699

if (isset($this->_options['grid']['recordsPerPage'])) {
should be
if (isset($this->_options['grid']['recordsPerPage']) && 
!isset($this->_recordsPerPage)) {

otherwise the value that was alreay set with $grid->setRecordsPerPage will be 
overwritten again with the value from the grid.ini

Original issue reported on code.google.com by buegelfa...@gmail.com on 15 Mar 2012 at 2:41

GoogleCodeExporter commented 9 years ago
Hi,

It make sense $grid->setRecordsPerPage overwrite global set at grid.ini. 
However, isset($this->_recordsPerPage) will always return true because is set a 
default value:

protected $_recordsPerPage = 15;

The solution can be set $_recordsPerPage as null. In the code verify if 
$_recordsPerPage still null (no var set at grid.ini neither by 
$grid->setRecordsPerPage) and set a default value.

Best Regards
Ivo Monteiro

Original comment by ivomonte...@gmail.com on 17 Mar 2012 at 10:41

GoogleCodeExporter commented 9 years ago
Hi,

All is working as expected. After viewing the code you only must call 
$grid->setRecordsPerPage() after $grid->setSource()/$grid->query().

Please, can you verify where you are calling $grid->setRecordsPerPage()?

Best Regards
Ivo Monteiro

Original comment by ivomonte...@gmail.com on 18 Mar 2012 at 11:12

GoogleCodeExporter commented 9 years ago
Hi,

confirmed, it works when I call $grid->setRecordsPerPage after $grid->setSource.
This should be in the documentation!

Otherwise I think this this should be changed, in my mind the more logical way 
to handle this is: configure the grid first THEN put data into the grid and 
output it.
Also, other config options, e.g. setNoOrder, updateColumn, etc. etc. ALL work 
*before* $grid->setSource so why should only one option work *after* that??

Kind regards

Original comment by buegelfa...@gmail.com on 19 Mar 2012 at 10:40

GoogleCodeExporter commented 9 years ago
Hi,

I prefer use setSource() at first and then set all options. This also happen in 
ZFDataGrid example (check siteController.php).

I agree with you, this info should be in documentation.

Best Regards
Ivo Monteiro

Original comment by ivomonte...@gmail.com on 19 Mar 2012 at 6:57