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

Dynamicaly Hide Tables

2 Answers 40 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Frank
Top achievements
Rank 1
Frank asked on 28 Jul 2016, 09:18 PM

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 Answers, 1 is accepted

Sort by
0
Frank
Top achievements
Rank 1
answered on 28 Jul 2016, 10:55 PM
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. 
0
Stef
Telerik team
answered on 29 Jul 2016, 08:23 AM
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
Tags
General Discussions
Asked by
Frank
Top achievements
Rank 1
Answers by
Frank
Top achievements
Rank 1
Stef
Telerik team
Share this question
or