mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-09-06 01:31:22 +02:00
Merge pull request #3567 from stephenmcm/gridfieldexportbutton-patch
FIX GridFieldExportButton exporting only Paginated list when using ArrayList as source
This commit is contained in:
commit
c8ad29f0d7
@ -118,7 +118,10 @@ class GridFieldExportButton implements GridField_HTMLProvider, GridField_ActionP
|
|||||||
$fileData .= "\"" . implode("\"{$separator}\"", array_values($headers)) . "\"";
|
$fileData .= "\"" . implode("\"{$separator}\"", array_values($headers)) . "\"";
|
||||||
$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?
|
||||||
|
@ -73,6 +73,27 @@ class GridFieldExportButtonTest extends SapphireTest {
|
|||||||
$button->generateExportFileData($this->gridField)
|
$button->generateExportFileData($this->gridField)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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 {
|
||||||
|
Loading…
Reference in New Issue
Block a user