how to get drill report pages and set pagination in drill report using visualize.js

Hello,

I want to set pagination in my drill report using visualize.js, but i am not able do this.

kchavda's picture
89
Joined: Jun 15 2015 - 5:08am
Last seen: 6 years 11 months ago

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);
            }
        });

 

 

 

jclarke_1's picture
491
Joined: Feb 9 2015 - 9:09am
Last seen: 6 years 7 months ago
Feedback
randomness