views:

739

answers:

4

how to hide columns in crystal report at run time? thanks for any suggistions.

+2  A: 

You could use parameters (which values can be set during runtime) and use them on the objects' suppress formula.

Jojo Sardez
ok Jojo, if I have 3 columns and I want to hide second one, is this way done without empty spaces.Thanks alot for you.
Dani AM
+1  A: 

Option 1: use conditional-suppression logic to hide/show redundant fields

Use a parameter field to drive the suppression formulae for the desired fields.

If you want to eliminate blank spaces between fields, then you'll need to stack the fields on top of each other and suppress them appropriately. In your example, column 2 would contain field2 and field3 (both suppressed) and column 3 would contain field2 and field3 (both suppressed). The suppression logic, in your example, would continue to suppress both fields in column 2, but would show field3 in column 2 (field2 in column 2 would still be suppressed).

Option 2: use 'placeholder' formula field

Each column of data that could be suppressed would be a formula field. Each formula field would use SELECT CASE logic to choose the desired field to display. A 'hidden' field would simply return a null value. Your SELECT CASE logic would be written to ensure that values are filled from left to right. The formatting will need to be done in the formula rather than on the formula field itself.

Option 3: use the SDK to dynamically-change the report.

Use the CR .Net SDK or the older CRAXDRT API to dynamically-modify the columns' visibility and positioning.

If you use this option, however, your deployment options will be more restricted.

Craig
+1 That is what I would do as a CR specialist. The simpler the better, keep it simple! So, the simpler is doing it within a condition of Suppression. You may also Suppress Blank Sections.
Will Marcouiller
Thank you Craig for your answer so,what do you mean about 'placeholder', and as Will Marcouiller said how can I Suppress Blank Sections? Thanks alot for your time. another Q is there dynamic report allow to end user to show\hide columns optionally? and thanks for Will Marcouiller
Dani AM
@Dani AM: In this context, a 'placeholder' is a formula field that's value is calculated dynamically. "Suppress Blank Section" is a property of the section--it will hide an entire row if all of the fields in that row are null. Based on your description, I don't think that this what you want. Crystal Reports doesn't have a 'dynamic' report per se. You could try a cross-tab, but that probably won't meet your needs. You could try creating a report dynamically with either of the SDKs that I mention, but this is more complex.
Craig
Ok I'm working on the first option, for dynamic report if I want to generate dynamic report without using SDK,Is sql reporting a good choise.I appreciate your response.
Dani AM
@Dani AM: What you mean by 'sql reporting'? Microsoft SSRS?
Craig
I realy sorry about delay....yes i mean that. By the way I finished my task and do it in conditional-suppression .
Dani AM
A: 

Hi guys, just for sharing I found a great and simple article at

http://www.codeproject.com/KB/cs/Dynamic_Crystal_Report.aspx

that using parameters in crystal report to dynamically load data from a database into Crystal Report and show specifying which field (Columns of a particular table) should be displayed in the repor according to user choice.

Dani.

Dani AM
A: 

Can any one give an idea how to remove blank space after supressing any coloumn ...

heya..