JS to refresh the current page

  • Last update:May 28, 2025
  • Overview

    Expected Effect

    Example one: refresh after successful data entry, as shown in the following figure

    动图1.gif

    Example two: refresh by button clicking, as shown in the following figure

    动图2.gif

    Implementation Method

    You can refresh a page by location.reload() or _g().refreshAllSheets(). The following table introduces the difference between the two APIs.

    location.reload()
    _g().refreshAllSheets()
    • The effect is that the whole template is refreshed. You can realize the same effect by manually clicking the refresh icon in the browser.

    • The selected parameter on the parameter panel will be reset.

    • If multiple sheets exist, the first sheet will be returned after a refresh.

    • This API is supported on mobile terminals.

    • The effect is that the query is performed again. You can realize the same effect by clicking the query button.

    • The selected parameter on the parameter panel will not be reset.

    • If multiple sheets exist, the current sheet will be returned after a refresh.

    • This API is supported on mobile terminals.

    Example One: Refresh After Successful Data Entry

    Data Preparation

    Create a general report and create a dataset ds1 with the SQL statement SELECT * FROM EMPLOYEE.

    1.png

    Table Design

    Design the table as shown in the following figure. For details about procedures, see Free Report Data Entry.

    2.png

    Event Adding

    Choose Template > Web Attribute > Data Entry Setting on the menu bar, select Set for This Template Separately in Following Settings, and add a Data Entry Successful event in Event Setting, as shown in the following figure.

    3.png

    The JavaScript code is as follows:

    setTimeout(function() {
           _g().refreshAllSheets();
           //location.reload();
    }, 500)

    Effect Display

    1. PC

    Save the report and click Data Entry Preview. The following figure shows the refresh effect after successful data entry.

    动图3.gif

    2. Mobile Terminal

    移动端效果.gif

    Example Two: Refresh by Button Clicking

    Template Preparation

    4.png

    Event Adding

    1. Enter the parameter panel, drag a button widget into the panel, and modify the name of the button to Refresh, as shown in the following figure.

    5.png

    2. Select the button widget and add a click event, as shown in the following figure.

    6.png

    The JavaScript code is as follows:

    setTimeout(function() {
           //_g().refreshAllSheets();
           location.reload();
    }, 500)

    Effect Display

    iconNote:
    This solution is not supported on mobile terminals.

    Save the template and click Data Entry Preview. The following figure shows the refresh effect.

    动图5.gif

    Template Download

    Example One

    For details, you can download the template Refresh After Successful Data Entry.cpt.

    Example Two

    For details, you can download the template Refresh by Button Clicking.cpt.

    Attachment List


    Theme: Data Entry
    • Helpful
    • Not helpful
    • Only read

    滑鼠選中內容,快速回饋問題

    滑鼠選中存在疑惑的內容,即可快速回饋問題,我們將會跟進處理。

    不再提示

    10s後關閉

    Get
    Help
    Online Support
    Professional technical support is provided to quickly help you solve problems.
    Online support is available from 9:00-12:00 and 13:30-17:30 on weekdays.
    Page Feedback
    You can provide suggestions and feedback for the current web page.
    Pre-Sales Consultation
    Business Consultation
    Business: international@fanruan.com
    Support: support@fanruan.com
    Page Feedback
    *Problem Type
    Cannot be empty
    Problem Description
    0/1000
    Cannot be empty

    Submitted successfully

    Network busy