Hello,
I want to set pagination in my drill report using visualize.js, but i am not able do this.
1 Answer:
Have you set the report up to be paginated? There are steps you need to take in Jasper studio to make the report HTML appear one page at a time. From there, you can use visualize to page forward and back.
Here's a code snippet from our app (we are using AngularJS):
var _goToPage = function(pageNum) {
var deferred = $q.defer();
$rootScope.isLoading = true;
_report.pages(pageNum).run()
.done(function(data) {
$rootScope.isLoading = false;
deferred.resolve(true);
})
.fail(function(err) {
$rootScope.isLoading = false;
deferred.resolve(false);
_handleError("An error occurred while trying to load the specified page of this report.", err);
});
return deferred.promise;
};
Also, you'll need to be able to determine the total number of pages to prevent the user from paging past the end. The way this is implemented in Visualize is a little weird - you need to grab a callback when the report is built, like this:
_report = _reportService.report({
resource: uri,
container: containerId,
runImmediately: false,
events: {
changeTotalPages: function(totalPages) {
EventService.pub("PAGE_COUNT_CHANGED", {pageCount: totalPages, container: containerId});
}
},
linkOptions: {
events: {
"click": function(evt, link){
_fireReportClickEvent(evt, link);
}
}
},
error: function (err) {
_handleError("An error occurred while attempting to load the list of reports. " + err.message, err);
}
});