Merge pull request #3567 from stephenmcm/gridfieldexportbutton-patch

FIX GridFieldExportButton exporting only Paginated list when using ArrayList as source
This commit is contained in:
Loz Calver 2014-10-28 11:33:42 +00:00
commit c8ad29f0d7
2 changed files with 25 additions and 1 deletions

View File

@ -119,6 +119,9 @@ class GridFieldExportButton implements GridField_HTMLProvider, GridField_ActionP
$fileData .= "\n"; $fileData .= "\n";
} }
//Remove GridFieldPaginator as we're going to export the entire list.
$gridField->getConfig()->removeComponentsByType('GridFieldPaginator');
$items = $gridField->getManipulatedList(); $items = $gridField->getManipulatedList();
// @todo should GridFieldComponents change behaviour based on whether others are available in the config? // @todo should GridFieldComponents change behaviour based on whether others are available in the config?

View File

@ -74,6 +74,27 @@ class GridFieldExportButtonTest extends SapphireTest {
); );
} }
public function testArrayListInput() {
$button = new GridFieldExportButton();
$this->gridField->getConfig()->addComponent(new GridFieldPaginator());
//Create an ArrayList 1 greater the Paginator's default 15 rows
$arrayList = new ArrayList();
for ($i = 1; $i <= 16; $i++) {
$dataobject = new DataObject(
array ( 'ID' => $i )
);
$arrayList->add($dataobject);
}
$this->gridField->setList($arrayList);
$this->assertEquals(
"\"ID\"\n\"1\"\n\"2\"\n\"3\"\n\"4\"\n\"5\"\n\"6\"\n\"7\"\n\"8\"\n"
."\"9\"\n\"10\"\n\"11\"\n\"12\"\n\"13\"\n\"14\"\n\"15\"\n\"16\"\n",
$button->generateExportFileData($this->gridField)
);
}
} }
class GridFieldExportButtonTest_Team extends DataObject implements TestOnly { class GridFieldExportButtonTest_Team extends DataObject implements TestOnly {