Setting the Report Body to Be Unavailable by JS

  • Last update:July 10, 2025
  • Overview

    Problem

    During report development, you often need to set the report body or toolbar to be unavailable. Namely, the report and toolbar are grayed out and cannot be clicked. Or you need to set the report body or toolbar to be unavailable upon initialization and restore their availability by clicking a button. The following figure shows the effect of the grayed-out report. How to realize the effect?

    Implementation Method

    You can add a JS Loading End event for the template to gray out the report body and make the report non-editable.

    Example

    Template Preparation

    Prepare a template. The example is the built-in template First_Form.cpt in FineReport installation directory\webapps\webroot\WEB-INF\reportlets\doc-EN\Form.

    For details, you can download the example template First_Form.cpt.

    Event Adding

    Unavailable Report Body

    Open the template, choose Template > Web Attribute > Data Entry Setting, select Set for This Template Separately in Following Settings, and add a Loading End event to set the report body to be grayed out and unavailable, as shown in the following figure.

    The JavaScript code is as follows.

    $('<div id="lock"/>').css({
        position:'absolute',//The absolute position
        top:$('.x-toolbar').height(),//The distance from the element to the top is the height of the toolbar.
        width: '100%',//Display the report in full width.
        height: '100%',//Display the report in full height.
        filter: 'alpha(opacity=50)',//Set the opacity to 0.5.
        opacity: 0.5,
        '-moz-opacity': 0.5,
        'z-index': 10000,
        background: '#cccccc'//Set the background color.
    }).appendTo($('body'));

    Unavailable Report Body and Toolbar

    The section "Unavailable Report Body" shows how to set the report body to be grayed out and unavailable. If you also need to set the toolbar to be grayed out and unavailable, you just need to modify the distance from the element to the top to zero in JS, as shown in the following figure.

    The JavaScript code is as follows.

    $('<div id="lock"/>').css({
        position:'absolute',//The absolute position
        top:0,//The distance from the element to the top is zero.
        width: '100%',//Display the report in full width.
        height: '100%',//Display the report in full height.
        filter: 'alpha(opacity=50)',//Set the opacity to 0.5.
        opacity: 0.5,
        '-moz-opacity': 0.5,
        'z-index': 10000,
        background: '#cccccc'//Set the background color.
    }).appendTo($('body'));

    Clicking the Button to Restore the Availability of the Report Body

    The section "Unavailable Report Body" shows how to set the report body to be grayed out and unavailable. If you want the report to be unavailable upon initialization and restore the availability of the report after clicking a button on the toolbar, you need to add id to div for identification in JS, and add a Click event for the button on the toolbar to remove the grayed-out state of the report based on id, as shown in the following figure.

    1. Choose Template > Web Attribute > Data Entry Setting, select Set for This Template Separately in Following Settings, and add a Loading End event, as shown in the following figure.

    The JavaScript code is as follows.

    $('<div id="lock"/>').css({
        position:'absolute',//The absolute position
        top:$('.x-toolbar').height(),//The distance from the element to the top is the height of the toolbar.
        width: '100%',//Display the report in full width.
        height: '100%',//Display the report in full height.
        filter: 'alpha(opacity=50)',//Set the opacity to 0.5.
        opacity: 0.5,
        '-moz-opacity': 0.5,
        'z-index': 10000,
        background: '#cccccc'//Set the background color.
    }).appendTo($('body'));

    2. Add a custom button to the toolbar, modify the button name and icon, and add a custom event for the button, as shown in the following figure.

    The JavaScript code is as follows.

    document.getElementById("lock").remove();

    Effect Preview

    Save the template and click Data Entry Preview. The following figures show the preview effect on the PC.

    Unavailable Report Body

    Unavailable Report Body and Toolbar

    Clicking the Button to Restore the Availability of the Report Body

    iconNote:
    The effect cannot be previewed on mobile terminals.

    Template Download

    For details, you can download the template Setting the Report Body to Be Unavailable by JS - Example One.cpt.

    For details, you can download the template Setting the Report Body to Be Unavailable by JS - Example Two.cpt.

    For details, you can download the template Setting the Report Body to Be Unavailable by JS - Example Three.cpt.

    Attachment List


    Theme: Secondary Development
    • 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