Any way to set up default Filter on a Grid?

For example lets say I have a orders database with orders in different states.
In process
Waiting parts
Shipped
In Shipping etc…

You get the idea.

Now when the grid of orders opens I want to view only orders that are in process as default, I can do this with a Where in the SQL but I might want to look at orders that are waiting parts at some point or the ones that are in shipping and the where clause excludes those from loading.

I know I can add a dynamic search to the grid and limit it that way but if possible I don’t want to do a search to start I would rather be able to see the default and look at those and then only search if I want to see the others.

Any ideas?

one way might be to use a global variable in your where clause like

where [myselect];

In the onscriptinit you can set [myselect]=‘myargument = “something”’;

this will set the sql statement initially. If you define a button to ‘reset’ the ‘where’ you are able to use the advanced search.

You can use:

sc_apl_conf("my_grid", "start", "filter");

Note: I believe though that this needs to be set in a different application than the one it is to apply too - usually from the menu app, but can be anywhere.

Albert @aducom
How would I define a button to ‘reset’ the where?
Thanks.

First set the default argument of [myselect] in the menu execute event which calls your application.
Next create a button of type php called ‘reset’. In the phpcode you set [myselect]=‘1=1’; // needed because else you would have an empty where clause
Then do a sc_exit(sel); to load the same application again. You need to move the initial value outside of the application as onapplicationinit will fire again. Other option is to set the global in the onapplicationinit which is fired only once.

I just had to do the same thing, but achieved it slightly differently.

In the main menu, I am actually defining the entire menu already so that I can pass variables to the applications. I really wish we could do this in the GUI!

sc_appmenu_add_item(“Main_Menu”, “main_21”, “main_2”, “All Orgs”, “orgs_grid_main”, “min_status=active”);

Inside the Grid Application --> script init
// Hide inactive by default (takes value from menu app)
echo [min_status];
if ([min_status] == “active”) {
$sql_where = " and status != 0";
sc_select_where(add) = $sql_where;
}

this sc_apl_conf(“my_grid”, “start”, “filter”) don’t work, did you use it?