How to Get a Grid to Refresh Programmatically

I have a grid application with some action buttons. One of these, when pressed, will perform bulk changes in the database tables that the grid is based on. Thus, after the code that changes the database has executed, I would like for the grid to be refreshed and any dynamic and/or advanced search criteria to be cleared. I have looked at the SC macros to find one that would do this for me with no luck.

Is there a suitable macro, or is there another way to do it with PHP code (i.e. in the PHP Code section of the action button)?

Did you tried sc_ajax_refresh();?

Good suggestion. Unfortunately, it cannot be used in the PHP code for a button. It gives the following error:
“Fatal error: Call to undefined function sc_ajax_refresh() in … {application name} line …”

So I need to be able to make the grid refresh and clear any dynamic and/or advanced search criteria from the PHP code of a button.

I found the SC macro: sc_exit(sel) or sc_exit(ref).
It will restart the application directly and thereby refresh the grid. It will, however, not remove any criteria on the grid, which is fine.
If the grid is to be totally reset, on can use sc_redir and point to the same application.

agreed with orion tho another way of doing this is with an sc_redir, that will force the application to refresh

regards

[QUOTE=kafecadm;38799]agreed with orion tho another way of doing this is with an sc_redir, that will force the application to refresh

regards[/QUOTE]

Yes, I agree, but I did not suggested this because sc_redir don’t clear criterias, and about sc_ajax_refresh() wasn’t sure because I didn’t tried.

hey Giu:

How about using an sc_redir with an sc_reset_apl_conf… would dat work?.

Regards

I don’t think so, but it’s worth a try.

If not, maybe, playing with WHERE macros, and manipulating manually “SC_Gb_Free_cmp” session value for groupby, could do the trick.

I’m sure is more easy than we offer, but right now my brain is collapsed

This may help, see http://solidlystated.com/scripting/php-refresh-page/

Automatic refresh a grid: Grid / Settings / Refresh Interval in seconds

Clear search criteria in forms (!):


$_SESSION['sc_session'][$this->Ini->sc_page]['<your_form>']['where_filter']   = "";
$_SESSION['sc_session'][$this->Ini->sc_page]['<your_form>']['fast_search'][0] = "";
$_SESSION['sc_session'][$this->Ini->sc_page]['<your_form>']['fast_search'][1] = "";
$_SESSION['sc_session'][$this->Ini->sc_page]['<your_form>']['fast_search'][2] = "";

(in onLoad-Event)

I’am not sure that works with grids, but try it …

Thanks for the suggestions Larry and RHS!

I think that the refresh method (http://solidlystated.com/scripting/php-refresh-page/) will work something like the sc_exit macro. I will have a look next time.

The Grid / Settings / Refresh Interval in seconds is very interesting. I have some parts of an application where I plan for the user to get updates on how a background process is doing (i.e. it logs in the database as work is done). A automatic refreshing grid will be just the thing.

Can you just use sc_redir ?

www.LiviApps.com (Scriptcase Specialist - English language)
www.OwenSolution.com (Scriptcase Specialist - Indonesian language)

How about this: https://en.wikipedia.org/wiki/Meta_refresh