Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Show/Hide columns at runtime...

Status
Not open for further replies.

bgravi

Programmer
Jul 28, 2002
15
0
0
US
I need to develop a report which initially shows a few fields. The user has an option of selecting the columns he want to see by selecting them from an option provided. My questions are:

1. Can I make a report which hides/shows certain columns? I tried to do this by suppressing them at runtime, but the other columns do not auto-arrange themselves. This leaves a big blank where the fields were earlier.

2. Since the user can select the fields/columns to see, I cannot create reports(rpt files) for each scenario as the permutations are too much. How can this be designed in a graceful manner?

I am using C# and Crystal Report.Net available in VS.Net. Any help will be greatly appreciated.

Thank you all
 
Depending on how many fields you want to show (I would limit this to a maximum of ten on a report)

create a function for each one of the ten and then assign a paramater to each field you wish to show.

Then using if then else in each function assign the parameter to a field, this will give you control over the data that is shown , Im not sure about the length of fields that can be used,I have never quite grasped the field length stuff in CR but Im sure you could probably using LEFT{,x} to control the length of data that is being shown.

It also allows you to control the grouping of data
eg you pick your first function to be date, and you group by function 1 hence you get grouped/sorted by date.


I would also consider the size of paper you are printing to, if you can use a snaller size, remember a4 landscape is same width as a3 portrait, so if your using ten fields can it be fitted on a smaller page, hence no big ugly spaces


James Flowers
 
Hi James,
Thanks for your reply.
I am a newbie in CrystalReports. Can you please give me a small sample code as an example so that I can understand your solution better?

Thanks
 
Create a three parameters with three options

1
2
3

function 1
IF {?PARAM1}='1' THEN {YOURFIELD1}
ELSE IF {?PARAM1}='2' THEN {YOURFIELD2}
ELSE IF {?PARAM1}='3' THEN {YOURFIELD3}

function 2
IF {?PARAM2}='1' THEN {YOURFIELD1}
ELSE IF {?PARAM2}='2' THEN {YOURFIELD2}
ELSE IF {?PARAM2}='3' THEN {YOURFIELD3}

function 3
IF {?PARAM3}='1' THEN {YOURFIELD1}
ELSE IF {?PARAM3}='2' THEN {YOURFIELD2}
ELSE IF {?PARAM3}='3' THEN {YOURFIELD3}

Then put the functions on the report.

This will dynamically change the source of the fields at runtime.

Insert a group based upon function1, function2 and this will group the info (I have found) into a more readable format.


hope this helps

James Flowers
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top