mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
Merge pull request #4767 from tractorcow/pulls/3.2/fix-print-limit
BUG Fix print button only displaying first page
This commit is contained in:
commit
5f17618096
@ -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) {
|
||||
|
46
tests/forms/gridfield/GridFieldPrintButtonTest.php
Normal file
46
tests/forms/gridfield/GridFieldPrintButtonTest.php
Normal file
@ -0,0 +1,46 @@
|
||||
<?php
|
||||
|
||||
|
||||
class GridFieldPrintButtonTest extends SapphireTest {
|
||||
|
||||
protected $extraDataObjects = array(
|
||||
'GridFieldPrintButtonTest_DO'
|
||||
);
|
||||
|
||||
public function setUp() {
|
||||
parent::setUp();
|
||||
|
||||
// 42 items
|
||||
for($i = 1; $i <= 42; $i++) {
|
||||
$obj = new GridFieldPrintButtonTest_DO();
|
||||
$obj->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'
|
||||
);
|
||||
}
|
Loading…
Reference in New Issue
Block a user