Page anchors

Control report pagination with page anchors.

by srikar7

HTML

<script src="https://code.jquery.com/jquery-2.1.0.js"></script>
<script src="https://mobiledemo.jaspersoft.com/jasperserver-pro/client/visualize.js"></script>
<div style="font-size: 11pt">Report will load default anchor "Cliffside"</div>
<br><br>
Go to a report anchor: <input type="text" id="anchor"/>
<div style="font-size: 9pt">For example: Bellingham</div>
<br><br>
<div id="container"></div>

CSS

#container {
    height: 400px;
    overflow-y: scroll;
    width: 100%;
}

JavaScript

visualize({
    auth: {
        name: "joeuser",
        password: "joeuser",
        organization: "organization_1"
    }
}, function (v) {

    var report = v.report({
        resource: "/public/Samples/Reports/17._Report_Workbook",
        container: "#container",
        success:refreshSa,
        
        error: function(e) {
            alert(e);
        }
    });
    function refreshSa(datas){
    console.log(datas.links);}
    $("#anchor").on("change", function() {
        report
            .pages({ anchor: $(this).val() })
            .run()
            .fail(function(e) { alert(e); });
    });
});