JS Display and Hide toolbar according to Username

  • Last update:December 28, 2020
  • I. Overview

    1.1 Problem description

    In the decision-making platform, when different roles view the same template, the toolbars they see can be defined separately through Fine-grained Permission Control.

    But for different users with the same role, how to achieve this effect?

    1.2 Solution

    Add the Start Loading event, judge the user name, and then displays or hides the toolbar.

    II. Example

    2.1 Open the template

    Open the report: %FR_HOME%\WebReport\WEB-INF\reportlets\demo\Data Entry\Basic Data Entry.cpt.

    2.2 Add event

    Select Template > Web Attributess > Data Entry Settings, and add a Start Loading event.

    Add a parameter named T, and the parameter value is defined by formula: $fine_username. Add JavaScript code,  as shown below:

    1.png

    The JavaScript code is as follows:

    if (T =='Anna') {
    //Hide the toolbar
    $('.x-toolbar').css('display','none');
    $('.reportPane').css('top', '0');
    } else {
    $('.x-toolbar').css('display','block');
    $('.reportPane').css('top', '28px');
    }


    2.3 Effect preview

    Save the template and mount it to the decision-making platform. Anna and the administrator (admin) can log in the platform to access the report, but Anna cannot see the toolbar.

    4.gif

    Note: Mobile terminal is not supported.

    III. Completed Template

    Attachment List


    Theme: Decision-making Platform
    • 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