logo
small logo
  • Products
  • Buy
  • Support
  • Articles
  • Customer panel Support
    • en
    • pt
    • es
    • de
    • pl
    • JP
    • ZH
  • Home
  • /
  • Articles
  • /
  • How to hide columns in a list if there is no data
  • MS Word format vs. Open Document Text. Which is better?

    October 19, 2020

    Speaking of text editors, we immediately present coryphaeus as Microsoft Word, which for many years

    read more
  • Starting an application with FastReport .NET in Docker with Linux

    November 17, 2021

    Docker is a software platform for rapid development, testing and launching of applications. Due to

    read more
  • Want to generate tables for a user - Excel or OpenOffice Calc?

    October 8, 2020

    Tables. For centuries, they have been used to present similar data for record-keeping, counting amounts,

    read more
  • How to select the top values in a matrix

    April 22, 2021

    The article is relevant until version 2022.1. FastReport .NET has a great tool for displaying data

    read more
  • How to protect your PDF?

    November 30, 2020

    On the Data protection day, we decided to prepare an article about the PDF documents

    read more

How to hide columns in a list if there is no data

April 7, 2020

When making the report, we want it to be "friendly" to the consumers as much as possible. Too much data and design elements processing makes people's understanding of information more unfavourable. As a result, many people want to delete spaces in a table without data. FastReport.Net report generator allows you to perform this function. As you understand, it is necessary not only to hide the column, but also a title for it. If hiding a column is a matter of a couple of clicks with a mouse, then hiding the title task is not trivial.

Suppose we have a table from which we want to display the data in a report. However, some data may be missing or set to zero. In this case, we can use the “Conditional Selection” tool to hide zero-data cells. Select the desired cell and click on the icon on the toolbar:

 

When you add conditions, by default there will be a check for zero. That is what we need. We only select display options. In our case, we remove the flag visible:

 

Therefore, these non-ingenious operations, we have realized a hidden zero-data cells. But that doesn't solve all the problems. Our task is to hide the title of the entire column if no value is greater than zero. The gap in this column will check the output of each page.

To check that there is no data on the page in a given column, we'll use the “result”.

This result is summed up by a given column and summarizes all the values in it. If the total is zero, then there is not a single value in the column more than zero, and you need to hide the column's header.

So. Let's add the result:

 

The result put in the band "Page Footer":

The result can then be hidden using the “visible” property.

Now let's set the logic to hide the headline of the last column. Instead of the RUB text, we introduce the expression:

[IIf([Total]!=0,Text14.Text = "RUB",Text14.Text = "")]

However, that is not all. Since the result is formed after the title and data are displayed on the page, at the time of execution of expression that we have introduced above, total value is not relevant. Therefore, we need to use the deferred expression calculation option in the column header and double pass on the report.

Choose a text box with the RUB column header. In the properties of the text field we find ProcessAt and change to PageFinished:

 

After this we need to open report properties and install “Doublepass” option:

 

This option allows you to build a report twice. In the first construction will be calculated all the results, and in the second one these results can be used in the headlines. All this is necessary, because the report is built elementally consistently. That is, when building the next element, you will not be able to change the previous one. Therefore, you need a re-build that takes into account the results of the next elements.

Let's see how our report works in terms of when all the data in the RUB column is 0:

 

On some pages the data can appear so the column will appear as well:

 

This way we can dynamically display or hide the columns according to the data in them.

about product download buy
avatar
Dmitriy Fedyashov
Technical Writer
Fast Reports Team: Dmitriy Fedyashov - Technical Writer at Fast Reports
.NET FastReport

Add comment
logo
  • 800-985-8986 (English, US)
  • +4930568373928 (German)
  • +55 19 98147-8148 (Portuguese)
  • info@fast-report.com
  • 901 N Pitt Str #325 Alexandria VA 22314
  • Buy
  • Download
  • Documentation
  • Testimonials
  • How to uninstall
  • Ticket system
  • FAQ
  • Tutorial Video
  • Forum
  • Articles
  • Our News
  • Press about us
  • Resellers
  • Extended licensing
  • Contact us

© 1998-2022 by Fast Reports Inc.

  • Privacy Policy