setting height and width of BIRT viewer dynamically based on contents
Asked Answered
G

2

8

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?

Gyrostat answered 4/1, 2017 at 12:6 Comment(0)
C
1

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?

Crippen answered 13/1, 2017 at 13:23 Comment(0)
H
0

i will suggest to use hight and width in percentage(%).

Also calculate window hight and width and use same for outer div.

for inner div use hight and width 100%, so inner div will be fixed in outer div and scroll will not appear on screen.

Hope this will help you. Thanks

Haileyhailfellowwellmet answered 19/1, 2017 at 6:26 Comment(1)
in rtpdesign file I cannot give %Durden

© 2022 - 2024 — McMap. All rights reserved.