Skip to content

Commit

Permalink
Merge pull request #49 from ishannz/pulls/export-with-filters
Browse files Browse the repository at this point in the history
ENH Retain filters when using SS report
  • Loading branch information
emteknetnz authored Aug 5, 2021
2 parents db70f89 + 9f5396e commit 36ea111
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion src/Jobs/GenerateCSVJob.php
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,7 @@ public function setGridField(GridField $gridField)
$this->GridFieldURL = $gridField->Link();
$this->GridFieldState = $gridField->getState()->toArray();
$this->totalSteps = $gridField->getManipulatedList()->count();
$this->Filters = Controller::curr()->getRequest()->getVar('filters');

return $this;
}
Expand Down Expand Up @@ -280,9 +281,18 @@ protected function getGridField()
$actionKey = 'action_gridFieldAlterAction?' . http_build_query(['StateID' => $id]);
$actionValue = 'Find Gridfield';

$queryParams = [$actionKey => $actionValue, 'SecurityID' => $token];

// Get the filters and assign to the url as a get parameter
if (is_array($this->Filters) && count($this->Filters) > 0) {
foreach ($this->Filters as $filter => $value) {
$queryParams['filters'][$filter] = $value;
}
}

$url = Controller::join_links(
$this->GridFieldURL,
'?' . http_build_query([$actionKey => $actionValue, 'SecurityID' => $token])
'?' . http_build_query($queryParams)
);

// Restore into the current session the user the job is exporting as
Expand Down

0 comments on commit 36ea111

Please sign in to comment.