resign Posted July 9, 2012 Share Posted July 9, 2012 Hello,Is it possible to insert parameters to report, which let me present a table with dynamical number of columns?The idea is: the user have the possibility to select any cols and export it to pdf as a table.Data to selected from:First name, last name , birth date, phone, mailThe user wants to seelast name, phoneAny ideas?Thanks,resign Link to comment Share on other sites More sharing options...
cmatthews Posted July 9, 2012 Share Posted July 9, 2012 If your not doing it in java code then the way I have done this is with parameters and subreports.Your sql statement should have something like this,IF ($P!{numberOfCols} = 4)BEGINSELECT $P!{columnOne} as columnOne, $P!{columnTwo} as columnTwo, $P!{columnThree} as columnThree, $P!{columnFour} as columnFour FROM sourceTableENDIn my edit I added the "as columnOne", I realized that is part of the key to solving for your need. This way the report doesn't care what you actually put in columnOne so long as the type is correct. I recommend using string for everything.You just call the subreport that will result in the correct column number, you could do this several ways but a couple ideas, have subreports for each column count depth and call the one that equals the column count. Or ... make one as wide as the greatest width of columns and set all the extra columns to null and use the option "blank when null".For the column headers you can have a variable declaration that would set the column headers text dynamically. Something like this,( $P{columnOne},equals("addressColumn") ) ? "Address" : $P{columnOne},equals("firstNameColumn") ) ? "First Name" : ""etc, etc, until all the possibiltiies are met.Hope this helps set you in a direction..ClarkPost Edited by cmatthews at 07/09/2012 16:30 Link to comment Share on other sites More sharing options...
resign Posted July 10, 2012 Author Share Posted July 10, 2012 holy shit,seems not to be simple.Thanks for answer,resign 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