This is a migrated thread and some comments may be shown as answers.

Hididng empty tables at run-time

5 Answers 281 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Stargazer
Top achievements
Rank 2
Stargazer asked on 29 Dec 2009, 06:48 PM
Hello!

Maybe I'm just tired and not seeing things right, but I have a report with several Tables which may or not display data. This is defined by the filters applied to them.

I define the DataSources of the report and tables before the report is processed and the tables have filters on them to show only the data relevant to the detail record. SO, my report is organized as follows:

  • Detail Section, databound to DataTable1;
  • Table1, filtered by the ID from the detail section), databound to DataTable2;
  • Table2, filtered by the ID from the detail section), databound to DataTable3;
  • Table3, filtered by the ID from the detail section), databound to DataTable4;

All the tables are set to show the headers in every page they appear.

My question: How do I check to see if those tables are displaying data or not, so I can hide them?

Regards!

5 Answers, 1 is accepted

Sort by
0
Accepted
Ivan
Telerik team
answered on 04 Jan 2010, 03:19 PM
Hi Stargazer,

You can handle the ItemDataBound event of the Table report item to check programmatically whether the current table contains no data and set its Visible property to false in such case. I have attached a small sample report which illustrates this approach.

If you have more questions regarding this, please do not hesitate to ask.

Kind regards,
Ivan
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
Stargazer
Top achievements
Rank 2
answered on 05 Jan 2010, 09:48 AM
Hello Ivan,

That's pretty much the approach I've used to accomplish what I've needed, some working hours after I wrote my initial post. Anyway, thanks! There's some differences between what I've used and the sample, so I'll check the best for me. I made something like this:

Telerik.Reporting.Processing.Table subjects = sender as Telerik.Reporting.Processing.Table; 
 
if (subjects.ChildElements.Count <= 14) 
    //subjects.Visible = false; 
    Telerik.Reporting.Processing.Panel painel = subjects.Parent as Telerik.Reporting.Processing.Panel; 
    painel.Visible = false

Your approach is more reliable, I think. I'll have to give it a go. Thanks!

Regards!

0
Ricardo Pinto
Top achievements
Rank 1
answered on 26 Apr 2010, 08:46 PM
Hello!

I have almost the same issue: a report with several tables, bound to the same sqldatasource, but with different filters.

But In my case, when there are no rows returned from the datasource in one of the tables, I would like to display a single row, with " - " in all the columns.

I tried the following, but with no success:

Private Sub OtherTextBox_ItemDataBound(ByVal sender As System.ObjectByVal e As System.EventArgs) Handles TextBox9.ItemDataBinding, TextBox11.ItemDataBinding 
        Dim textBox As Processing.TextBox = DirectCast(sender, Processing.TextBox) 
        Dim tableCell As Processing.TableCell = DirectCast(textBox.Parent, Processing.TableCell) 
        Dim table As Processing.Table = DirectCast(tableCell.Parent, Processing.Table) 
        If table.Rows.Count = 0 Then 
            textBox.Value = " --- " 
        End If 
    End Sub 


How can I do this?
Thanks in advance!

Ricardo.
0
Ivan
Telerik team
answered on 29 Apr 2010, 06:14 PM
Hello Ricardo Pinto,

Perhaps the simplest approach in your case is to add an empty row at the bottom of the table and apply a filtering condition to its corresponding row group so that the empty row is displayed only when the table contains no data. First you need to make the row group of the empty row dynamic by applying a constant grouping expression to it. After that you can use a filtering expression like the following one to display the group only when there is no data in the table:

= Count(1) = 0

To illustrate this approach I have attached a small sample project with two reports in it:
  • ServerFiltering report filters the data on the database server via where clause in the SQL query;
  • ClientFiltering report filters the data on the client application via filter condition applied to the table.
You can run the two reports trying different values for the report parameters to verify that the discussed technique works both ways. The reports need the "Adventure Works" sample database that comes with every installation of Telerik Reporting.

Regards,
Ivan
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
0
Ricardo Pinto
Top achievements
Rank 1
answered on 25 Jun 2010, 12:39 AM
Hello, Ivan!

That worked great :)
Thank you for the support,

Ricardo.
Tags
General Discussions
Asked by
Stargazer
Top achievements
Rank 2
Answers by
Ivan
Telerik team
Stargazer
Top achievements
Rank 2
Ricardo Pinto
Top achievements
Rank 1
Share this question
or