Jump to content

How to show/hide column in the report?


green4x

Recommended Posts

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

 

Link to comment
Share on other sites

  • Replies 5
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

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 

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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

 

Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...