-
Notifications
You must be signed in to change notification settings - Fork 5
/
example.html
95 lines (73 loc) · 3.22 KB
/
example.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
<!DOCTYPE HTML>
<html>
<head>
<title></title>
<meta charset="utf-8" />
<meta name="viewport" content="initial-scale=1, maximum-scale=1" />
<link type="text/css" rel="stylesheet" href="/src/rdljs.plugin.html.css" />
</head>
<body>
<script src="/lib/d3.js"></script>
<script src="/lib/jquery-2.1.3.js"></script>
<script src="/src/rdljs.core.js"></script>
<script src="/src/rdljs.util.js"></script>
<script src="/src/rdljs.plugin.abstract.js"></script>
<script src="/src/rdljs.js"></script>
<script src="/src/rdljs.plugin.html.js"></script>
<select id="report">
<option value=""></option>
<option value="ReportWithCustomAssembly">ReportWithCustomAssembly</option>
<option value="OrdersWithDrillthrough">OrdersWithDrillthrough</option>
<option value="OrdersWithSubreport">OrdersWithSubreport</option>
</select>
<div data-role='input-container'>
</div>
<button data-role='trigger-load' style="display: none">Load</button>
<script type="text/javascript">
$(document).on("change", "#report", function (e) {
var url = "reports/" + $("#report").val() + ".rdlc";
$.get(url).done(function (xml, status, xhr) {
var report = rdl.makeReport(xhr.responseText);
report.dataResolver(function (dataSetName, inputData) {
var dataSet = this.report.findDataSet(dataSetName);
return $.ajax({
url: "http://localhost/NorthwindApi/query",
method: "post",
data: {
type: dataSet.query.commandType(),
text: dataSet.query.commandText(),
inputData: inputData
},
beforeSend: function (xhr) {
xhr.overrideMimeType("application/json; charset=utf8");
}
});
});
var renderer = rdl.rendererFor("html");
$(report.inputParameters()).each(function (i, param) {
$("<div><label></label><input /></div>")
.find("label")
.attr("for", param.name())
.text(param.name())
.end()
.find("input")
.attr("name", param.name())
.change(function (e) {
report.findParameter($(e.target).attr("name")).value($(e.target).val());
})
.end()
.attr("data-input-field", "true")
.appendTo("[data-role='input-container']")
});
$("[data-role='trigger-load']").show();
$(document).on("click", "[data-role='trigger-load']", function () {
$("#report").remove();
$("[data-role='input-container']").remove();
$("[data-role='trigger-load']").remove();
report.load(renderer);
});
});
});
</script>
</body>
</html>