JS Keep title centered when scrolling

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

    1.1 Problem

    When the report scrolls horizontally, sometimes we want the title to be always at the center. The effect is as follows. How can we achieve this effect?

    js-1.gif


    1.2 Solution

    Use JS to change the grid layout, and then set the left and upper margin.

    Note: This method does not support mobile devices.

    II. Example

    Design the report and drag a great many data columns into the report.

    Add a title, merge the heading cells, and adjust the styles.

    image.png

    Click Template -> Web Attributes -> Data Entry Settings, choose to set individually for this template. Add a Loading End event using the following JS:

    image (1).png

    var $bt=$('td[id^=B1-]'); //Get cell object. B1 is the title cell.
    $bt.css('position','fixed'); //Set the position to be fixed.
    $bt.css('left',(document.body.clientWidth-$bt.width())/2-$('td[id^=B3-]').width());
    //Set the left margin and subtract the width of the frozen column. B3 is the left-most data cell.
    $bt.css('top','50px'); //Set upper margin.

    Note: This method also applies to the report to be scrolled vertically.

    Save and data entry preview, and the effect will be like:

    js-1.gif

    III. Download 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