我希望你们当中很少有人有过Jaspersoft报告及其新的visualise.js api的经验。
visualise.js没有生成报表导出文件,我有一个问题。所发生的是:
下面是我为此使用的代码(我使用纯文本auth进行测试):
visualize({
auth: {
name: "mylogin",
password: "mypass",
organization: "organization_1"
}
}, function (v) {
var $select = buildControl("Export to: ", v.report.exportFormats),
$button = $("#button"),
report = v.report({
resource: "/FPSReports/journal",
container: "#export",
params: {
"journal_ref": [ "<?php echo $reference; ?>" ],
},
success: function () {
button.removeAttribute("disabled");
},
error : function (error) {
console.log(error);
}
});
$button.click(function () {
console.log($select.val());
report.export({
// export options here
outputFormat: $select.val(),
// exports all pages if not specified
// pages: "1-2"
}, function (link) {
var url = link.href ? link.href : link;
window.location.href = url;
}, function (error) {
console.log(error);
});
});
function buildControl(name, options){
function buildOptions(options) {
var template = "<option>{value}</option>";
return options.reduce(function (memo, option) {
return memo + template.replace("{value}", option);
}, "")
}
var template = "<label>{label}</label><select>{options}</select><br />",
content = template.replace("{label}", name)
.replace("{options}", buildOptions(options));
var $control = $(content);
$control.insertBefore($("#button"));
//return select
return $($control[1]);
}
});HTML:
<div class="grid">
<div class="grid-8"></div>
<div class="grid-8 center"><a href="" id="button" class="large link_button margin2">Export</a></div>
<div class="grid-8"></div>
</div>
<div class="grid">
<div class="grid-24" id="export"></div>
</div>唯一的参数来自URI段(我正在使用codeigniter框架):
$reference = $this->uri->segment(3, 0);发布于 2016-02-06 15:41:46
我找到了一个似乎可行的答案,并解决了这个问题。张贴在这里,以防其他人有这个特定的问题,像我一样。
简单地说,:在花了几个小时查看控制台调试输出之后,我意识到每次我试图发送导出请求时,都会打开一个新会话。而不注销前一个。很明显那是不-不。我不太了解JS,但据我所知,请求中存在会话id不匹配。请在此纠正我:)
这个问题的解决方案(例如,如果您有visualize.js的身份验证问题)非常简单。在全局配置中设置身份验证:
visualize.config({
auth: {
name: "superuser",
password: "superuser"
}
});无论您使用的是令牌、纯文本还是其他任何东西,auth都可以通过api获得。
然后在你的网站上的任何地方做你的东西:
visualize(function (v) {
v("#container1").report({
resource: "/public/Samples/Reports/06g.ProfitDetailReport",
error: function (err) {
alert(err.message);
}
});
});
visualize(function (v) {
v("#container2").report({
resource: "/public/Samples/Reports/State_Performance",
error: function (err) {
alert(err.message);
}
});
});一切都应该像对我一样对你起作用。这在visualize.js的版本5.6和6.1中是可行的。
进一步阅读和链接我的研究:
Token based authentication to Jasper reports failing when used with visualize.js
Visualize.js authentication error after second login
http://community.jaspersoft.com/questions/842695/visualizejs-authentication-error
http://community.jaspersoft.com/questions/845886/authentication-error-refresh-credentials-visualizejs
代码示例(5.6): Community/sozzq0sL/embedded/
Api样品(6.1): http://community.jaspersoft.com/wiki/visualizejs-api-samples-v61
Api样品(5.6): http://community.jaspersoft.com/wiki/visualizejs-api-notes-and-samples-v56
真的希望这能帮助像我这样的Jaspersoft & visualize.js新手。
https://stackoverflow.com/questions/35176370
复制相似问题