JS Scroll to the Bottom or Right of the Browser Automatically

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

    1.1 Expected effect

    If the template adopts Data Analysis Preview or Data Entry Preview, because there is no pagination, the page after preview is usually large.

    Users need to scroll to the bottom or right of the browser to view or fill the latest data. As shown below:

    5.png

     

    1.2 Implementation ideas

    This effect can be achieved by adding a Loading End event.

    II. Example 1: Report without frozen rows

    2.1 Open the template

    Open the template: %FR_HOME%\webapps\webroot\WEB-INF\reportlets\demo\data entry\batch deletion.cpt.

    2.2 Add event

    Click Template > Web Attributes > Data Entry Settings, choose to Individually set for the template, and add the Loading End event, as shown in the following figure:

    1.png

    The JavaScript code is as follows:

    setTimeout(function(){
      var y=contentPane.$contentPane[0].scrollHeight;//Get the maximum height of the page
      var x=contentPane.$contentPane[0].scrollWidth;//Get the maximum width of the page
      contentPane.$contentPane.scrollLeft(x);//Set the leftmost position of the scroll bar
      contentPane.$contentPane.scrollTop(y);//Set the topmost position of the scroll bar
    },100)

    Note 1: At the end of the page loading, some settings may not been loaded yet, and using the setTimeout() function will make the report more compatible.

    Note 2: Multi-sheet reports are not supported.

     

    2.3 Effect preview

    Save the template, click Data Entry Preview, the preview effect on the PC side is as shown in the figure below:

    2.png

    Note 1: If the desktop resolution is high, sometimes the effect may not be seen. You can shrink the browser window and refresh the page to check the effect.

    Note 2: Mobile terminal is not supported.

    III. Example 2: Report with frozen rows

    3.1 Open the template

    Open the template: %FR_HOME%\webapps\webroot\WEB-INF\reportlets\demo\data entry\batch deletion.cpt.

     

    3.2 Set frozen rows

    Click Template > Duplicate and Freeze, and select Freeze from row 1 to row 6 for Data Entry Preview. As shown below:

    3.png

     

    3.3 Add event

    Click Template > Web Attributes > Data Entry settings, choose to Individually se for the template, and add a Loading End event, as shown in the following figure:

    4.png

    The JavaScript code is as follows:

    setTimeout(function(){
    var a=$("#frozen-center")[0];
    var y=a.scrollHeight;//Get the maximum height of the page
    var x=a.scrollWidth;//Get the maximum width of the page
    a.scrollLeft=x;
    a.scrollTop=y;
    },100)


    3.4 Effect preview

    Save the template, click Data Entry Preview, the preview effect on the PC side is as shown in the figure below:

    5 (1).png

    Note 1: If the desktop resolution is high, sometimes the effect may not be seen. You can reduce the browser window and refresh the page to check the effect.

    Note 2: Mobile terminal is not supported.

    IV. Completed template

    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