Skip to content

Commit

Permalink
Fixed sorting: let the previous remain after filtering
Browse files Browse the repository at this point in the history
  • Loading branch information
paveljanda committed Jan 12, 2018
1 parent 67daa82 commit cc5fc26
Showing 1 changed file with 30 additions and 3 deletions.
33 changes: 30 additions & 3 deletions src/DataGrid.php
Original file line number Diff line number Diff line change
Expand Up @@ -1773,6 +1773,14 @@ public function filterSucceeded(Form $form)
/**
* Session stuff
*/
if ($this->remember_state && $this->getSessionData($key) != $value) {
/**
* Has been filter changed?
*/
$this->page = 1;
$this->saveSessionData('_grid_page', 1);
}

$this->saveSessionData($key, $value);

/**
Expand Down Expand Up @@ -2246,7 +2254,8 @@ public function handleSort(array $sort)

$this->saveSessionData('_grid_has_sorted', 1);
$this->saveSessionData('_grid_sort', $this->sort = $sort);
$this->reload(['table']);

$this->reloadTheWholeGrid();
}


Expand Down Expand Up @@ -2285,7 +2294,7 @@ public function handleResetFilter()

$this->filter = [];

$this->reload(['grid']);
$this->reloadTheWholeGrid();
}


Expand All @@ -2298,7 +2307,7 @@ public function handleResetColumnFilter($key)
$this->deleteSessionData($key);
unset($this->filter[$key]);

$this->reload(['grid']);
$this->reloadTheWholeGrid();
}


Expand Down Expand Up @@ -2509,6 +2518,24 @@ public function reload($snippets = [])
}


/**
* @return void
*/
public function reloadTheWholeGrid()
{
if ($this->getPresenter()->isAjax()) {
$this->redrawControl('grid');

$this->getPresenter()->payload->_datagrid_url = $this->refresh_url;
$this->getPresenter()->payload->_datagrid_name = $this->getName();

$this->onRedraw();
} else {
$this->getPresenter()->redirect('this');
}
}


/**
* Handler for column status
* @param string $id
Expand Down

0 comments on commit cc5fc26

Please sign in to comment.