Dynamicaly Hide Tables

3 posts, 0 answers
  1. Frank
    Frank avatar
    86 posts
    Member since:
    Mar 2012

    Posted 28 Jul Link to this post

    I am now trying to hide hole table dynamicaly but I am having an odd issue

    This will not work, none of the table show

    var performSubReportTable = performSubReport.Items.Find("table1", true)[0] as Table;
    var performSubReportTable2 = performSubReport.Items.Find("table2", true)[0] as Table;
     
    if (show1 == 1)
    {
        performSubReportTable2.DataSource = performanceDataSet;
        performSubReportTable.Visible = false;
    }
    else
    {
        performSubReportTable.DataSource = performanceDataSet;
        performSubReportTable2.Visible = false;
    }

     

    This works for the true but the false the none of the table show

    var performSubReportTable = new Table();
    if (show1 == 1)
    {
        performSubReportTable  = performSubReport.Items.Find("table1", true)[0] as Table;
    }
    else
    {
        performSubReportTable = performSubReport.Items.Find("table2", true)[0] as Table;
    }
    performSubReportTable.DataSource = performanceDataSet;
    performSubReportTable.Visible = true;

     

    but this does work

    var performSubReportTable = performSubReport.Items.Find("table1", true)[0] as Table;
    var performSubReportTable2 = performSubReport.Items.Find("table2", true)[0] as Table;
    performSubReportTable.DataSource = performanceDataSet;
    performSubReportTable2.DataSource = performanceDataSet;
    if (show1 == 1)
        performSubReportTable.Visible = false;
    else
        performSubReportTable2.Visible = false;

    I would prefer if the second method since it is cleaner, but I am not sure why the first two ways wont work. 

    Then big difference is the first and the third I set the tables to be visible on the report.  The second method I set the table visibility to false on the report.

  2. Frank
    Frank avatar
    86 posts
    Member since:
    Mar 2012

    Posted 28 Jul Link to this post

    I have found that it will work in the first two examples if I am showing table1 and hiding table2.  The third version works regardless. 
  3. DevCraft banner
  4. Stef
    Admin
    Stef avatar
    3047 posts

    Posted 29 Jul Link to this post

    Hi Frank,

    Please check the data items' Name properties in the Report Explorer and if you are getting the right Table item.

    In addition, you can use conditional formatting or a binding to the Table.Visible properties based on a boolean report parameter. The report parameter's value can be updated through the wrapping ReportSource.Parameters collection - Report Sources.

    Regards,
    Stef
    Telerik by Progress
    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 Feedback Portal and vote to affect the priority of the items
Back to Top