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

0

Hello,

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

kchavda's picture
31
Joined: Jun 15 2015 - 5:08am
Last seen: 3 years 3 weeks ago

1 Answer:

0

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
Joined: Feb 9 2015 - 9:09am
Last seen: 2 years 9 months ago
Feedback