Hi all,
How to keep refined filters set when returning to the grid from a form linked to grid rows.
I got a grid with several refined search fields.
The user usually set filters and then he goes to navigate grid.
I got the possibility to link the related form clicking on action bar button or with html field.
On form, once edited or confirmed, I got a button to go back with classical sc_redir(grid).
When you come back the grid refreshes all and I lost all refined filter previously set.
How can avoid this behavior ?? Thanks
You can save the current where and use it when you access the grid again
in your grid
onScriptInit
if (!empty([last_where])) {
$Where_Current = {sc_where_current};
//Remove current where from last_where so only the new filters will be reinjected
$Where_Add = str_replace($Where_Current, "", [last_where]);
sc_select_where(add) = urldecode($Where_Add);
[last_where] = '';
}
onRecord
[current_where] = {sc_where_current};
in your form
onScriptInit
[last_where] = [current_where];
in you menu, just to be safe
onExecute
[last_where] = '';
[current_where] = '';
Thanks so much ! I will try !
How are you calling the form application? Through a link or using Ajax or one of the other events with sc_redir() on your grid? If you are calling the form via Ajax, how does sc_redir call look?
Then the form you opened, in what event are you are doing a sc_redir() back to the grid and what actions have enabled on the form (INSERT/UPDATE/DELETE)? How does your sc_redir call look? Are updating the grid table records with the form, or are you updating records on other tables?
(Questions is just to gauge your setup. There are a couple of options, but all depend on the above)
Thanks Dirk,
at the end the best and easy way was to use the Exit button instead of a custom button.
The standard Exit retains the refined filter set and, instead, sc_redir refresh all.
I will note both suggestions of you and jlboutin60 for a future use where I will not able to use Exit.