Successfully!

Error!

JS Get Data in a Specified Cell of Report Block

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

    Add a JavaScript-type hyperlink to a cell in the report block of the dashboard, the cell can display a cell value whose coordinates correspond to that specified by JavaScript.

    II. Example

    2.1 Data preparation

    Create a new dataset ds1, and the SQL statement is:

    SELECT * FROM SALES_BASIC

    1606445119309413.png


    2.2 Design report block

    Drag a report block to the dashboard body and the design of the report block is shown in the figure below:

    1606445119707495.png

    The data column in cell B2 is set to be shown in the form of Summary, as shown in the figure below:

    1606445179445895.png

    Enter the formula in cell C2: ROUND(B2 / B3 * 100, 2) + "%", which calculates the sales proportion of each salesperson.

    1606445179649143.png


    2.3 Add a hyperlink

    Select cell B2 and add a JavaScript-type hyperlink. Add a parameter named row and the parameter value is formula: row()

    1606445242201250.png

    The JS code is as follows:

    var ele = "td[id^=C" + row + "]"; //Get the coordinates of the cell, the row number is obtained through the parameter row, C is the column number
    var obj = _g().options.form.getWidgetByName("report0").
    element.click().find(ele).text(); //Get the value of the cell
    FR.Msg.alert('Proportion',obj);

    Note: report0 is the name of the report block object in the dashboard, and the object is obtained through the find method in the click event of JavaScript.


    2.4 Hidden cells

    Select column C and right click to Hide:

    1606445272420063.png

    Show only the first two columns of data

    1606445272606053.png

    III. Effect

    1606445273131138.gif

    Note: Mobile terminal is not supported.

    IV. Completed Template

    Attachment List


    Theme: Dashboard
    Already the First
    Already the Last
    • Helpful
    • Not helpful
    • Only read

    Doc Feedback