Basic Report Embed
Simple initialization of the library, plain text authentication and loading a report
by Gene Arnold
HTML
<script src="http://localhost:8080/jasperserver-pro/client/visualize.js"></script>
<div id="container" style="height: 200px;"></div>
CSS
#container {
width:400px;
}
JavaScript
visualize({
auth: {
name: "joeuser",
password: "joeuser",
organization: "organization_1"
}
}, function (v) {
//render report from provided resource
v("#container").report({
resource: "/public/Samples/Reports/Cascading_Report_2_Updated",
error: handleError,
linkOptions: {
beforeRender: function (linkToElemPairs) {
linkToElemPairs.forEach(showCursor);
},
events: {
"click": function(ev, link){
if (link.type == "myFunction"){
//alert(link.parameters.product_name);
console.log("Row Click");
}
}
}
}
});
//show error
function handleError(err) {
alert(err.message);
}
function showCursor(pair){
var el = pair.element;
el.style.cursor = "pointer";
}
});