How to show/hide column in the report?

Hi

Suppose I have 5 columns in my report: A, B. C, D. E and the user want  to choose what columns should be in the report (ex.: A,C,D or A,E or D,E only). Is it possible to do this in iReport?

I know the option “print when expression” but using it I’ll get “holes” in the report (where hidden columns are).

 

Thanks

 

green4x's picture
13
Joined: Aug 9 2010 - 10:37pm
Last seen: 10 years 3 months ago

4 Answers:

Hi green4x,

To implement the above what can be done is you cold make use of the overlays . Its explained further.

 

Suppose initially the column layout is col1,col2,col3,col4,col5

Then seuppose you want to print col1,col2,col4,col5 -  col3 goes missing, then col4 should extend and col3 should disaapear completely. , without developing any holes which a print when expression does.

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 Expressions as per you requirement  .The original col3 header and data field would contain print when expression which gets it diappear in the changes scenario and appears  for normal scenario 

So applying this will completly dissappear the column for the layout. Basically you will have to take care of the print when expressions of the overlay datafield and column headers which would appear when some column goes missing and vice-versa.

 

Hope the above explantion helps

 

Thanks,

Ankur Gupta 

Ankur Gupta's picture
Joined: Jan 21 2013 - 10:36pm
Last seen: 3 days 19 hours ago

Thanks!
So you advise to have 3 columns:
- col3
- col4
- col4' that overlaps col3 in case it should be hidden.

In the scenario when we don't need col3 we hide col3 and col4 and shows col4', right?

The problem I can have up to 20 columns and don't know exactly how many of them should be hidden/visible at user's wish. In that case overlapping is... ahmm.. too many combinations should be implement in the case of 20 columns. But this is right if I understood your suggestion properly.

green4x - 10 years 3 months ago

Hi ,

What I have presented is a suggestion and have included only 3 cols as it would be easy to express. See its completely your choice , like which fields should overlap , as you could decide the priority of the columns based upon the data , see if the extreme left or right columns need to be disappeared , you could just give a simple print when expression to make them disappear , no need to overlap there , because they do not contribute in the layout , or as in don't disturb the design of the data , but if the column to be disappeared lies in between then you have no choice to use , overlapping concept which I have explained in the previous answer.

 

So , in this overlapping case, yes it is a bit tiring but is the best solution for this case. So need to implement according to the needs. and effectiveness.

 

Hope it helps.

Thanks,

Ankur Gupta

Ankur Gupta's picture
Joined: Jan 21 2013 - 10:36pm
Last seen: 3 days 19 hours ago

Can you use a table instead?  Using a table with the Print When statements will cause the table to reflow.

Using your example if I hide C but leave a,b,d,e, a table will cause d to appear next to b.

StevenCrawford's picture
Joined: Feb 19 2013 - 8:09am
Last seen: 3 years 4 months ago

Hi,

If you using Jaspersoft 4.7 or later then table component have hide and show column feature.

I did similar kind of report,

I had to provide  22 columns for user selection any combination of columns, If you try to do this manually then it requires to choose user selected values sequence of columns through java and various tabular structure overlapping this makes report complex and slower. 

So better way is make a union query where you convert your columns into rows ,

ex: select col1,col2, col3 as KPI name

from tab

union

select col4, col 5, col 6 as KPI name

from tab2 ........................

and you can provide a kpi name as filter to report then use KPI name in crosstab so that depend upon your selection the no. df columns change dynamically.

Try this may be helpful.

Regards

Ajinkya

 

ajinkya_c's picture
7263
Joined: Aug 29 2012 - 6:13am
Last seen: 6 years 6 months ago
Feedback
randomness