JS Refresh the Parent Window after the Child Window is Close

  • Last update:  2020-12-15
  • I. Overview

    1.1 Requirement

    When performing data entry in a particular project, we might have to jump to a child window by clicking a button to fill in details and expect the parent window to be refreshed upon closing the child window after data entry has been completed. How can we make settings so that the parent window is refreshed when the child window is closed?

     


    1.2 Solution

    In the process of data entry, when we link to a subreport, the previous page can be reloaded and refreshed by adding a Loading End event in Data Entry Settings.

    Two methods are available:

    1) Refresh the parent window through window.opener.location.reload() when quitting the child window.

    2) Trigger an onunload event when we quit the page.

    A combination of the two events can enable the effect we want.

    II. Sample

    2.1 Create a new parent window

    1) Create a new parent window and add a dataset ds1: 

    SELECT * FROM userinfo

    The design interface is shown below:


    2.2 Create a new child data entry window

    1) The design interface of the child data entry window is shown below:

     

    2) Set data entry attributes:

     

    Click [Template]>[Web Attributes]>[Data Entry Settings] and click Event Settings to add a Loading End event.

    Input the following JS codes:

    window.onunload = function(){ this.opener.location.reload(); }

     

    2.3 Link the parent window and the child window

    Add a hyperlink to the cell A1 in the parent window and select the type as Web Report.

    The child window is the target report to be opened (a relative path is used in the figure below, and the parent and child windows should be placed in the same directory) and the link is opened in a new window, which passes a parameter op.

     


    2.4 Preview

    Save the template and click [Data Entry Preview]. The effect is shown in the figure below:

     

    III. Download the templates

    1) Parent window

    Parent window.cpt


    2) Child window

    Child window.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