anand.p Posted June 14, 2013 Share Posted June 14, 2013 HiI am struggling with a problem.Actaully I have to generate a report on a condition that if any column does not have value it should totally disappear from the report .I went through the table component where i can see the condition in property section "Column Print When" but I'm unable to figure out that what condition i should use there so that it evaluate whole column to make it disappear from the report if it does not contains any value.I need quik help in this part. Please if anyone have any idea about this part please rplyThanksAnand Link to comment Share on other sites More sharing options...
Ankur Gupta Posted June 14, 2013 Share Posted June 14, 2013 Hi anand.p ,What you can do are two things , First which is a easier and prefered way is that , suppose a field contains a feild expression as $F{Amount} , then in the print when expression for that particular field you write the expression as $F[Amount]!=null Other way is that you can see one of the property of the textfield as 'Remove line Blank ' you could check that and this will definitely solve the purpose. Hope that above explanation helpsThanks,Ankur Link to comment Share on other sites More sharing options...
anand.p Posted June 15, 2013 Author Share Posted June 15, 2013 Hi Ankur Thanks for you help but this was not my question exactly. This can be done at report level in properties which I'm aware of very well. My question is little bit tricky. It was to disappear whole column section from the report along with column header dynamically if that column does't not contains any value. I hope I'm able to make you clear what I want to know. Its like if one column does not have any value (In whole database) than it should not be included in report itself dynamically. Link to comment Share on other sites More sharing options...
Ankur Gupta Posted June 16, 2013 Share Posted June 16, 2013 Hi anand.p,For this problem what can be done suppose a field $F{Amount} is there , so you can add a variable which counts whether or not the values are present in the particular coulmn and then this variable can be used in the Print when expression for the Column header and the column field (Print When Expression as $V{COUNT} != 0).So in this way this is dynamically checked wether or not any value or record for a particular column is present for not, and accordingly the column disappears. Above is one scenario.,Another could be if you totally want to get it disappeared from the layout so that if a particular coulmn is absent then next colmn extends.In this case also you need to declare a a varibale which checks whether the data is present in a particular colum as done in the above scenario.For this you will have to place overlays, suppose col1,col2,col3,col4,col5 are in the original scenario but suppose, col3 goes missing, then col4 should extend and col3 should disaapear completely.For that you will need to place a column header and data feild too , overlapping column header and data feild on col3 and col4 which will contain the Print When Expression as $V{COUNT} == 0 (This count would tell if col3 is empty and will print this larger field) [same expression will be there for larger datafield] and the original col3 header and data field would contain $V{COUNT} != 0 for the normal scenario when the data is present in the column,So applying this will completly dissappear the column for the layout.I hope that this explanation helps. Thanks.Ankur Gupta Link to comment Share on other sites More sharing options...
madhukiran Posted July 5, 2013 Share Posted July 5, 2013 Hi Ankur, I assume anand is asking about the table componenet, that is where you have the "Column print when " option.. I think your answer is for a normal layout and not using a table component!! Even I have the same query.. has anyone hidden column in a table component based on a condition using values from the Dataset columns? This is throwing an error saying 'Field not found 'or 'parameter not found'.. Link to comment Share on other sites More sharing options...
art2006 Posted March 6, 2015 Share Posted March 6, 2015 The error is raised because in your table datasource you dont have the field that you use for hiding or showing the columns. Link to comment Share on other sites More sharing options...
art2006 Posted March 6, 2015 Share Posted March 6, 2015 Did you manage to make it? I am facing the same problem and making a calculation to resize next columns feels like a bad trick.Thanks in advanceAna Link to comment Share on other sites More sharing options...
jasperjones999 Posted February 12, 2018 Share Posted February 12, 2018 I dont think any of these answers are correct !try adding an expression to the "Column" (not the cell)!$F{columnYourHiding}.toString().isEmpty() -- assumes the col is a string typeOn "cell tab" -> "Print When Expression" field Link to comment Share on other sites More sharing options...
gloria.goldin Posted July 4, 2018 Share Posted July 4, 2018 jasperjones999, sorry but it isn't working for me.Also if the expression is true the column is hidden. I'm working with a table in JasperReport version 6.5.0Thank you, Gloria 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