Hididng empty tables at run-time

6 posts, 1 answers
  1. Stargazer
    Stargazer avatar
    73 posts
    Member since:
    Jan 2007

    Posted 29 Dec 2009 Link to this post

    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!
  2. Answer
    Ivan
    Admin
    Ivan avatar
    111 posts

    Posted 04 Jan 2010 Link to this post

    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.
  3. DevCraft banner
  4. Stargazer
    Stargazer avatar
    73 posts
    Member since:
    Jan 2007

    Posted 05 Jan 2010 Link to this post

    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!

  5. Ricardo Pinto
    Ricardo Pinto avatar
    36 posts
    Member since:
    Sep 2008

    Posted 26 Apr 2010 Link to this post

    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.
  6. Ivan
    Admin
    Ivan avatar
    111 posts

    Posted 29 Apr 2010 Link to this post

    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.
  7. Ricardo Pinto
    Ricardo Pinto avatar
    36 posts
    Member since:
    Sep 2008

    Posted 24 Jun 2010 Link to this post

    Hello, Ivan!

    That worked great :)
    Thank you for the support,

    Ricardo.
Back to Top
DevCraft banner