$_GET parameters missing when filtering
spernica opened this issue · comments
When you use own filter form and send this filter form to get url like /orders?surname=Ginev and then click on sorting the grid ends up in start state. This feature will be very helpfull to others too.
Datagrid.php line 354 - instead:
$filters->toArray(), 'page' => 1, 'per_page' => $per_page]
change to:
$filter = ['f' => $filters->toArray(), 'page' => 1, 'per_page' => $per_page];
return empty($_GET) ? $filter : array_merge($_GET, $filter);
You can always change the "filters" array like so:
$filters = $request->input('f', []);
$filters['test'] = $_GET['test']; // Or merge arrays etc.
$users = $userModel
->with(['roles'])
->clients()
->filter($filters)
->paginate(config('pagination.per_page'));
$grid = new Datagrid($users, $filters);
It's not the case, I know how to use filter. But it's about filtering and then sorting.
Filter something - then sort it.
Let's say you have 10 users in table. Filter 5 rows by surname. But if you click on sort, then your filter dissapear and you see 10 users instead of 5 filtered.