hide columns in crystal report at run time?

11,596

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.

Share:
11,596
Dani AM
Author by

Dani AM

Updated on June 04, 2022

Comments

  • Dani AM
    Dani AM almost 2 years

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

  • Dani AM
    Dani AM about 14 years
    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.
  • Will Marcouiller
    Will Marcouiller about 14 years
    +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.
  • Dani AM
    Dani AM about 14 years
    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
  • craig
    craig about 14 years
    @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.
  • Dani AM
    Dani AM about 14 years
    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.
  • craig
    craig about 14 years
    @Dani AM: What you mean by 'sql reporting'? Microsoft SSRS?
  • Dani AM
    Dani AM about 14 years
    I realy sorry about delay.... yes i mean that. By the way I finished my task and do it in conditional-suppression .