Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

showing all records using the setRecordsPerPage method does not work when a start value is present #894

Open
danhammari opened this issue Apr 5, 2014 · 2 comments

Comments

@danhammari
Copy link

When showing all records in a grid, shouldn't the grid ignore the record start value? I have added a pagination control to the grid so a user can select the number of items to show per page. This pagination control includes the value zero, which should show all records. However, if a user selects the zero value on the pagination control when not on the first page of the grid, the start value is retained and the grid shows all records except for those that occurred before the start value.

$per_page = Zend_Controller_Front::getInstance()->getRequest()->getParam('perPage',false);
if($per_page !== false){
    $grid->setRecordsPerPage($per_page);
}
$pagination_interval = array(12=>'12',25=>'25',50=>'50',100=>'100',0=>'ALL');
$grid->setPaginationInterval($pagination_interval);

I would think that the grid should automatically recognize that all records are being asked for and ignore the start value. Or is there some way to suppress the start value so it isn't passed in the get values of the URL when selecting a pagination interval value of zero? I have gone through the documentation, but have not found a way to override the start value parameter.

@danhammari
Copy link
Author

Here is the workaround I am using in the zend controller's init() method to suppress the division by zero error that occurs when "perPage" is set to zero and "start" is specified:

        // mitigate zfdatagrid perPage/start conflict
        if( $this->getRequest()->getParam( 'perPage', false ) === '0' ){
            if( $this->getRequest()->getParam( 'start', false ) !== false ){
                $this->getRequest()->setParam( 'start', 0 );
            }
        }

@danhammari
Copy link
Author

Here is the warning I get when perPage is set to zero and start is not zero:

Warning: Division by zero in \Bvb\Grid\Deploy\Table.php on line 1358

I am using Bvb_Grid version 0.8

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant