Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

setting height and width of BIRT viewer dynamically based on contents

Tags:

jsp

birt

I constructed a report by using BIRT and Data tables. Everything is working as expected. However height and width of BIRT viewer aren't dynamic. They are static and hence scroll is applied. So I wrote a code to make height and width of BIRT viewer dynamic.

function resizeFrame(e,f){
        var x = document.getElementsByTagName("iframe");

        var winW = 1112, winH = 486;
        if (document.body && document.body.offsetWidth) {
            winW = document.body.offsetWidth;
            winH = document.body.offsetHeight;
        }
        if (document.compatMode=='CSS1Compat' && document.documentElement && document.documentElement.offsetWidth ) {
            winW = document.documentElement.offsetWidth;
            winH = document.documentElement.offsetHeight;
        }
        if (window.innerWidth && window.innerHeight) {
            winW = window.innerWidth;
            winH = window.innerHeight;
        }

        x[0].style.width = winW + "px";
        x[0].style.height = winH + "px";

        console.log(f,e);
    }  

BIRT code is:

<birt:viewer id="birtViewer" reportDesign="/sampleReport.rptdesign"
            pattern="run" height="700" width="1136" scrolling="none"
            showParameterPage="false" isHostPage="false">

        </birt:viewer>  

Please note that height and width of BIRT viewer are 700px and 1136px respectively. Above code isn't making height and width dynamic.
How can I make BIRT height and width dynamic? I've added a picture for clear understanding.BIRT
As you can see in picture, it is adding vertical scrolling. How to prevent that and make height of BIRT increase based on table height?

like image 392
Ajay Kulkarni Avatar asked Jan 04 '17 12:01

Ajay Kulkarni


1 Answers

were you able to trigger the function you wrote from the report? I don't think so. I would take a look at the code that 'builds' the viewer and runs the report.

After the report has been build and loaded, you can trigger the a javascript function to resize the window to fit it's content. More info here: http://www.eclipse.org/birt/documentation/integrating/viewer-usage.php

Not sure why you need this? Isn't it much easier to just open a full screen window?

like image 168
Jeroen Avatar answered Oct 23 '22 15:10

Jeroen