Jump to content
We've recently updated our Privacy Statement, available here ×
  • Visualize.js: Complete list of built in events for report rendering


    stasp
    • Version: v7.1, v7.1.0 Product: JasperReports® Server

    Why a separate article

    While the API Reference Documentation covers most of the available report rendering events, there are still a couple missing. In addition, the available events are somewhat scattered across the doc. This article has a simple purpose of having all the events available when rendering reports via Visualize.


    Events

    beforeRender

    Run custom code before report is rendered

    report.events({
        beforeRender: function(html) {
                // do something with HTML before it is rendered
        }
    });
    

    bookmarksReady

    Allows getting bookmarks information from a rendered report and navigate to a particular report section

    events: {
        bookmarksReady : function(bookmarks){
            bookmarks.forEach(function(bookmark){
                    //Handle bookmark rendering and navigation
            });
        }
    }
    

    canUndo / canRedo

    Happens after JIVE actions (both through UI and API).

    Boolean value is passed as an argument to event handler indicating whether undo or redo action is possible

    report.events({
        canUndo: function(undoPossible) {
            console.log(undoPossible);
        },
        canRedo: function(redoPossible) {\
            console.log(redoPossible);
        }
    });

    changePagesState

    Happens when after running report resulting page differs from the one in pages property. This may happen when navigating through report by anchor or after a JIVE action.

    Current page number is passed as an argument to event handler.

    report.events({
        changePagesState: function(currentPage) {
            console.log("Current page changed to " + currentPage);
        }
    });

    changeTotalPages

    Happens when number of report's pages is changed: when report execution is finished, or after a JIVE action (e.g. change of column font size).

    Total pages number is passed as an argument to event handler.

    report.events({
        changeTotalPages: function(totalPages) {
            console.log(totalPages);
        }
    });

    pageFinal

    Happens after final HTML page markup is loaded from the server.

    HTML markup is passed as an argument to even handler. This event happen before markup rendering.

    report.events({
        pageFinal: function(html) {
            // do something with final HTML page
        }
    });

    reportCompleted

    Happens after report is completed. When report returns "failed" or "cancelled" status the event takes place right after report status is updated. When report is in status "ready", event happens when HTML export and JIVE components are re-fetched from server and applied to the report.

    Report status ("ready", "failed" or "cancelled") and optional error object are passed as arguments to event handler.

    report.events({
        reportCompleted: function(status, error) {
            if (status === "ready") {
                // do something
            } else if (status === "failed") {
                error && alert(error);
            }
        }
    });

    reportPartsReady

    Similar to bookmarks in terms of handling. The event allows to get report parts information for a particular book report and navigate to specific page.

    The parts can be visually organised as report tabs.

    The sample below demonstrates two approaches for getting report parts: via reportCompleted event and via reportPartsReady

    var tablePartName = "Table", //we assume that the name exists in the report
        tablePart;               //we don't know it yet
    
    // #1 retrieving tablePart using reportCompleted event
    report.events({
        reportCompleted: function(status, error) {
            if (status === "ready") {
                report.data().reportParts.forEach(function(part) {
                    if (part.name === tablePartName) {
                        tablePart = part;\
                    }
                });
            } else if (status === "failed") {
                error && alert(error);
            }
        }
    });
      
    // #2 retrieving tablePart using reportPartsReady event
    report.events({
        reportPartsReady: function(parts) {
            parts.forEach(function(part) {
                if (part.name === tablePartName) {
                    tablePart = part;
                }
            });
        }
    });
    $("#go-to-table-part-buttton").click(function(){
        report.pages(tablePart.page).run(); 
    });

     


    User Feedback

    Recommended Comments

    There are no comments to display.



    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...