-
Notifications
You must be signed in to change notification settings - Fork 5
/
Using a Custom Data Adapter.html
93 lines (81 loc) · 3.28 KB
/
Using a Custom Data Adapter.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
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<link rel="shortcut icon" href="../favicon.ico" />
<title>Using a Custom Data Adapter</title>
<!-- Stimulsoft Reports.JS -->
<script src="../scripts/stimulsoft.reports.js" type="text/javascript"></script>
<script src="../scripts/stimulsoft.viewer.js" type="text/javascript"></script>
<script src="../scripts/stimulsoft.designer.js" type="text/javascript"></script>
<script src="../scripts/stimulsoft.blockly.editor.js" type="text/javascript"></script>
<!-- Report designer scripts, may be external -->
<script type="text/javascript">
// Set full screen mode for the designer
var options = new Stimulsoft.Designer.StiDesignerOptions();
options.appearance.fullScreenMode = true;
// Create the report designer with specified options
var designer = new Stimulsoft.Designer.StiDesigner(options, "StiDesigner", false);
Stimulsoft.Report.Dictionary.StiCustomDatabase.registerCustomDatabase({
serviceName: "MyDatabase",
sampleConnectionString: "123",
process: function (command, callback) {
if (command.command == "TestConnection") callback({ success: false, notice: "Error" });
if (command.command == "RetrieveSchema") callback({ success: true, data: demoData, types: demoDataTypes });
if (command.command == "RetrieveData") callback({ success: true, data: demoData[command.queryString], types: demoDataTypes[command.queryString] });
}
// data is only needed to specify the column types; it is enough to pass only the first line
// if there is no data, then types are taken from types
// and vice versa, if there are no types, the types are taken from data
});
// Create a new report instance
var report = new Stimulsoft.Report.StiReport();
// Load report from url
report.loadFile("../reports/CustomAdapter.mrt");
// Edit report template in the designer
designer.report = report;
// Show the report designer in the 'content' element
designer.renderHtml("content");
var demoData = {
Table1: [{
Column1: "value1",
Column2: 1,
Column3: Stimulsoft.System.Guid.newGuidString()
}, {
Column1: "value2",
Column2: 2,
Column3: Stimulsoft.System.Guid.newGuidString()
}, {
Column1: "value3",
Column2: 3
}
],
Table2: [{
Column1: "value1",
Column2: 1
}, {
Column1: "value2",
Column2: 2
}, {
Column1: "value3",
Column2: 3
}
]
};
var demoDataTypes = {
Table1: {
Column1: "string",
Column2: "number",
Column3: "Stimulsoft.System.Guid"
},
Table2: {
Column1: "string",
Column2: "Stimulsoft.System.Int32"
}
}
</script>
</head>
<body>
<div id="content"></div>
</body>
</html>