diff --git a/forms/gridfield/GridFieldPrintButton.php b/forms/gridfield/GridFieldPrintButton.php index 5b5803b4f..1e25a8d27 100644 --- a/forms/gridfield/GridFieldPrintButton.php +++ b/forms/gridfield/GridFieldPrintButton.php @@ -186,7 +186,7 @@ class GridFieldPrintButton implements GridField_HTMLProvider, GridField_ActionPr $items = $gridField->getManipulatedList(); $itemRows = new ArrayList(); - foreach($items as $item) { + foreach($items->limit(null) as $item) { $itemRow = new ArrayList(); foreach($printColumns as $field => $label) { diff --git a/tests/forms/gridfield/GridFieldPrintButtonTest.php b/tests/forms/gridfield/GridFieldPrintButtonTest.php new file mode 100644 index 000000000..384705908 --- /dev/null +++ b/tests/forms/gridfield/GridFieldPrintButtonTest.php @@ -0,0 +1,46 @@ +Name = "Object {$i}"; + $obj->write(); + } + } + + public function testLimit() { + $list = GridFieldPrintButtonTest_DO::get(); + + $button = new GridFieldPrintButton(); + $button->setPrintColumns(array('Name' => 'My Name')); + + // Get paginated gridfield config + $config = GridFieldConfig::create() + ->addComponent(new GridFieldPaginator(10)) + ->addComponent($button); + $gridField = new GridField('testfield', 'testfield', $list, $config); + $controller = new Controller(); + $form = new Form($controller, 'Form', new FieldList($gridField), new FieldList()); + + // Printed data should ignore pagination limit + $printData = $button->generatePrintData($gridField); + $rows = $printData->ItemRows; + $this->assertEquals(42, $rows->count()); + } +} + +class GridFieldPrintButtonTest_DO extends DataObject { + private static $db = array( + 'Name' => 'Varchar' + ); +}