The report content is not displayed when the query result is empty

  • Last update:  2022-01-07
  • I. Overview

    1. Problem description

    When querying the report, even if there is no query result, the header and footer information will be displayed. As shown below:

    1.png

    But we want the report area below to display nothing when the query result is empty, as if the query has never been executed. If the result can be queried, the report will be displayed normally. How to achieve it?


    2. Solution

    Select a cell where the query result is located. As described in 1.1, the query result is Region, and the cell showing the region is A2. Determine whether the cell is empty. If it is empty, the entire report area will be hidden.

    Hiding the report area can be achieved by setting the line height to 0 by the conditional formatting, or by writing a JavaScript script by adding a loading end event.


    II. Example

    1. Prepare data

    Create a new general report, create a new database query ds1, the SQL query statement is: SELECT * FROM SALES_VOLUME WHERE Region='${Region}', as shown in the following figure:

    2.png


    2. Form design

    Enter the title in cells A1~C1, insert the corresponding data column in cells A2~C2, set A2 and B2 Data Setting to Group, the expansion direction to ( Vertical expansion ), C2 data to Summary>Sum, and cell C3 Insert the formula SUM(C2). The table style is as shown in the figure below:

    3.png


    3. Parameter setting

    Add the parameter Region to the parameter pane, set the widget type to text field and the Widget Value to be empty, as shown in the following figure:

    4.png

    Save the report and click Pagination Preview. When the region is not entered or the entered region does not exist, that is, when the query result is empty, the effect is as shown in the figure below:

    5.png


    4. Scheme 1: Set conditional formatting

    Add a conditional formatting to the first cell of each row, set the row height to 0, the formula condition is formula type, and the formula is len(A2)=0.

    When the condition attributes are the same, you can select cells A1, A2, and A3 to add them at the same time.

    6.png


    5. Scheme 2: Add loading end event

    Select Template>Web Attributes>Pagination Preview (same settings in other preview modes), select Individually for the template, add the Loading end event in the Event Settings below, and enter the JavaScript code.

    The JavaScript code is as follows:

    if ($("[id^=A2]").text().length == 0) {
    $(".x-table").css("display""none");
    }

    The steps are shown in the figure below:

    7.png


    6. Effect preview

    1) PC terminal

    Save the report and click Pagination Preview. The above two schemes have the same effect, as shown in the figure below:

    8.gif

    2) Mobile terminal

    Both App and HTML5 are supported, and the effect is shown in the following figure:

    1.gif

    III. Template download

    The completed template can be found in:

    %FR_HOME%\webapps\webroot\WEB-INF\reportlets\doc-EN\ReportApplication\FeaturesApplication\The report content is not displayed when the query result is empty.cpt

    %FR_HOME%\webapps\webroot\WEB-INF\reportlets\doc-EN\ReportApplication\FeaturesApplication\The report content is not displayed when the query result is empty-JS.cpt

    Click to download the template:

    The report content is not displayed when the query result is empty.cpt

    The report content is not displayed when the query result is empty-JS.cpt

    Attachment List


    Theme: Report Features
    • 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