Reload grid data

Hi,
I believe this is a common need for AJAX web applications, but I couldn’t find anything in scriptcase site.
How do we reload grid data by code / macro ?
I need to refresh the underlying data for a particular grid (probably in a container application) without reloading the whole page.
Another need is, refreshing a grid periodically - say once a minute.

Any help will be greatly appreciated…

Thanks
Cemo

Re: Reload grid data

Hi cemo,

Set Grid -> Toolbar -> Options -> Refresh Interval.

Grid-Refresh with Ajax is not available … use sc_redir(your_grid.php).

Re: Reload grid data

Thanks for the reply.
Can I use “sc_redir” for a particular grid in a container or tab application ?

regards…
Cemo

1 Like

Hi guys.
I’m having the same issue.
How to use sc_redir correctly.

  • in my grid, I have a Link Button that displays another grid app in modal to perform specific action on its rows
  • I tried sc_exit(sel) which did not close the modal grid
  • I use now sc_exit(); which closes the modal grid but does not reload the data in the calling grid
    How can I use “sc_redir” from the modal grid t oget back to the calling App ?
    And I tried the “Refresh Interval” in the calling grid app: does not work at all …
    Thx a lot.

Hi !
You can also create a button for manual updates using sc_ajax_refresh();

1 Like

Hi vaufran.
Thx for your idea.
But this macro only works within an existing ajax “OnClick” event in the grid.
My issue is to reload the grid when the Modal Form launched from this grid is closing.
I found the following way: Reload master/detail grid after insert/update from a modal form

In the latest version there is a button in the toolbar “reload”. That is when manualy reload.
Before I made my own “reload-button” with code: location.reload();
On time bases there is the setting in the grid.
On an event: only when reload the grid.

Thx ctmservice.
I noticed the button in the new release. But I haven’t upgraded yet … waiting a few weeks to see how it goes :slight_smile:

I had a similar problem. I need it to refresh a grid data when the app got the focus, to show updated data, every time my app (that was on a menutab) got focus.
So i created this code on the event “onFooter” of the grid:

//autorefresh of data grid, when app get focus

?>
<SCRIPT type="text/javascript">
//refresh the data inside a grid when the app get focus
$(document).bind('focus', function() {
   console.log('welcome (back)');
	       ajax_navigate('fast_search', 'SC_all_Cmp_SCQS_qp_SCQS_'); //this code is the same that executes sc when you do a quicksearch without any parameter
}).bind('blur', function() {
   console.log('bye bye');
});
</SCRIPT>
<?PHP

Another method that reloads the grid (full page) when it gets focus

$(document).bind('focus', function() {
   console.log('welcome (back)');
	       sc_btn_php_refreshGrid();  // this is an php button
}).bind('blur', function() {
   console.log('bye bye');
});

//Also, with this method, you have to create a button of type php (in this case the button was named “php_refreshGrid”)
with the code:

sc_exit(sel);

Just thought I’d update this thread.

sc_ajax_refresh();

works nicely with action buttons in ajax mode.

Already exits an option into toolbar for that:
image