kolja.ehlersiconplc.com Posted November 28, 2008 Share Posted November 28, 2008 Is it possible to pass a Parameter to a Subreport to change the width of a textfield in the subreport dynamically? I know I could have maybe 10 Textfields: 50px, 100px, 150px .... and with a print when expression I could show one and hide the others. But is it not possible to change the width by parameter?Thanks Link to comment Share on other sites More sharing options...
lucianc Posted November 28, 2008 Share Posted November 28, 2008 Element widths cannot be changed via report parameters or other type of dynamic expressions.The only way of doing this is to use the JasperReports API by change the element width before filling the report. You would have to locate the specific JRElement instance in the JasperReport object and call setWidth on the element. Note that you would have to do this before starting to fill the report/subreport.Regards,Lucian Link to comment Share on other sites More sharing options...
guptarasmi Posted May 29, 2009 Share Posted May 29, 2009 I am facing the same problem of making a text element having dynamic width. Can you please post some code snippet for the solution that you are suggesting Link to comment Share on other sites More sharing options...
lucianc Posted June 3, 2009 Share Posted June 3, 2009 See below.Regards,LucianCode:JasperDesign design = xmlLoader.loadXML(..jrxmlStream..);JRElement[] elements = design.getDetail().getElements();String elementKey = ..key of element to modify..;int newWidth = ..new element width..;for (int i = 0; i < elements.length; i++){ JRDesignElement element = (JRDesignElement) elements[i]; if (elementKey.equals(element.getKey())) { element.setWidth(newWidth); }} Link to comment Share on other sites More sharing options...
nikitha Posted June 30, 2009 Share Posted June 30, 2009 Hi Lucian,Could you explain in clearly the code that you have wriiten, i have a requirement to set page height, page width of the report dynmaically.Could you write the code that i need to integrate it my requirement.Thanks,Naveen Chanda Link to comment Share on other sites More sharing options...
lucianc Posted July 1, 2009 Share Posted July 1, 2009 naveenjavaWrote: Could you explain in clearly the code that you have wriiten, i have a requirement to set page height, page width of the report dynmaically. Could you write the code that i need to integrate it my requirement. If you want to change the report page heitght and width see the JasperDesign.setPageWidth() and setPageHeight() methods.Regards,Lucian Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now