API CHANGE: Added targetFragment argument to GridFieldExportButton to control button placement. Moved search fields to 2nd argument.

This commit is contained in:
Sam Minnee 2012-03-09 16:48:08 +13:00
parent 039ba665d4
commit 92a3535455
1 changed files with 10 additions and 3 deletions

View File

@ -27,11 +27,18 @@ class GridFieldExportButton implements GridField_HTMLProvider, GridField_ActionP
* @var boolean
*/
protected $csvHasHeader = true;
/**
* Fragment to write the button to
*/
protected $targetFragment;
/**
* @param array
* @param string $targetFragment The HTML fragment to write the button into
* @param array $exportColumns The columns to include in the export
*/
public function __construct($exportColumns = null) {
public function __construct($targetFragment = "after", $exportColumns = null) {
$this->targetFragment = $targetFragment;
$this->exportColumns = $exportColumns;
}
@ -49,7 +56,7 @@ class GridFieldExportButton implements GridField_HTMLProvider, GridField_ActionP
$button->setAttribute('data-icon', 'download-csv');
$button->addExtraClass('no-ajax');
return array(
'after' => '<p>' . $button->Field() . '</p>',
$this->targetFragment => '<p>' . $button->Field() . '</p>',
);
}