JS Hide Columns or Rows by Clicking a Button

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

    1.1 Requirement

    When performing data entry, how to hide certain rows and columns by using a button widget?


    1.2 Solution

    Hide rows and columns by using a button widget to add a Click Event.

    Note

    Export is not supported.

    II. Sample 1: Hide Row

    2.1 Create a new template

    Create a new regular report as follows:

     


    2.2 Set a button widget

    Select A1 and click Widget. Set the Widget Type as Button Widget, the Button Type as Common, and the Button Name as Hide the second, third and fourth row, as shown below:

     


    2.3 Add a Click Event

    Select A1, click Widget>Event to add a Click Event, and input the JavaScript code, as shown below:

     

    Input the JS code:

    $("#r-1-0").toggle();
    $("#r-2-0").toggle();
    $("#r-3-0").toggle();
    if (contentPane.curLGP.$editor) {
       contentPane.curLGP.$editor.toggle();
    }

    When there is more than one sheet in the template, input the following JavaScript code:

    $("#r-1-0").toggle();
    $("#r-2-0").toggle();
    $("#r-3-0").toggle();
    if (contentPane.curLGP.$editor) {
       contentPane.curLGP.$editor.toggle();
    }

    Note

    In $("#r-1-0"), 0 represents the row where the Sheet is located (starting from row 0)


    2.4 Preview

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

     

    III. Sample 2: Hide Column

    3.1 Create a new template

    Create a regular report as follows:

     


    3.2 Set a button widget

    Select A1 and click Widget. Set the Widget Type as Button Widget, the Button Type as Common, and the Button Name as Hide columns B and C, as shown below:


    3.3 Add a Click event

    Select A1, click Widget>Event to add a Click Event, and input the JavaScript code, as shown below:

     

    Input the JS code:

    $("td[id^='B']").toggle();//Hide column B 
    $("td[id^='C']").toggle();//Hide column C

    When there is more than one sheet in the template, input the following JavaScript code:

    $("#B1-0-0").toggle();//Hide column B
    $("#C1-0-0").toggle();//Hide column C

    Note

    In $("B1-0-0"), the first 0 represents the column where the sheet is located(starting from column 0).

     

    3.4 Preview

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

     

    IV. Download templates

    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