Skip to content

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

Open

Description

@danhammari

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.

Activity

  1. danhammari commented on Apr 7, 2014

    @danhammari
    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 );
                }
            }
    
  2. danhammari commented on Apr 7, 2014

    @danhammari
    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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions