I. Overview
1.1 Requirement
How to get the value of a cell in a report block of a dashboard, as shown below:
1.2 Solution
Add a JS event to the button widget to get the value of A1 in report0:
1.2.1 Method 1
var a=$("tr[tridx=0]","div#REPORT0").children().eq(0).html();
Note
In which, tridx=0 is the line number and eq(0) is the column number.
1.2.2 Method 2
var a = _g().options.form.getWidgetByName("report0").element.find("td[id^=A1-]").text();
II. Sample
2.1 Create a dashboard
Create a dashboard and add a report block which is designed as follows:
2.2 Add a button widget
Add two buttons respectively named [Get cell value-method 1] and [Get cell value-method 2] in the dashboard, as shown below:
2.3 Add a click event to the button widget
2.3.1 Method 1
Click on the button and add a click event, as shown below:
Input the following JS codes:
var a = $("tr[tridx=0]", "div#REPORT0").children().eq(0).html();alert(a);
2.3.2 Method 2
Click on the button and add a click event, as shown below:
Input the following JS codes:
var a = _g().options.form.getWidgetByName("report0").element.find("td[id^=A1-]").text();
alert(a);
2.4 Preview
Save the template and click [Preview]. By clicking the button, a dialog box named East China will pop up. See “1.1 Requirement” for the effect picture.