Jump to content
We've recently updated our Privacy Statement, available here ×

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


kchavda

Recommended Posts

  • 3 weeks later...
  • Replies 1
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

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

 

 

 

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...