Page 1 of 1
Missing data sources
Posted: Wed Nov 10, 2010 10:54 am
by Tobias
During runtime not all the data I had during design time might be available. I do:
StiOptions.Dictionary.HideRelationExceptions = true;
...to just ignore errors resulting from missing data.
The problem is that now a Databand that doesn't have a existing datasource shows the data from a completely different datasource with the same columns.
So is there a better way to handle "optional" data sources, which might not be available when printing the report?
Tobias
Missing data sources
Posted: Wed Nov 10, 2010 12:52 pm
by Jan
Hello Tobias,
Can you explain what you mean under "Databand that doesn't have a existing datasource". May be small sample project which illustrate this problem possible?
Thank you.
Missing data sources
Posted: Wed Nov 10, 2010 2:45 pm
by Tobias
Lets say I do RegData("foo", fooData) and RegData("bar", barData). This creates two datasources. In the designer I add databand "A" for "foo" and "B" for "bar".
But when printing the report, fooData might not be available (NO RegData("foo", fooData)!). This means the datasource "foo" associated to databand "A" is not available.
What happens now, is that in databand "A" the data from datasource "bar" gets printed.
The problem ist, that data sources I register with RegData() are generated dynamically depending on the available data. So not all datasources I used during the report design are available when actually printing the report from the template.
Missing data sources
Posted: Thu Nov 11, 2010 5:19 am
by Alex K.
Hello,
In this case you can hide element on DataBand without datasource
for example:
Code: Select all
StiReport report = new StiReport();
report.Load("d:\\Report.mrt");
StiDataBand bandProducts = report.GetComponents()["DataProducts"] as StiDataBand;
foreach (StiText text in bandProducts.Components)
{
text.Text = "";
}
report.Show();
Thank you.
Missing data sources
Posted: Thu Nov 11, 2010 6:40 am
by Tobias
Thanks for the hint! But then I need to know which DataBands are connected to a DataSource without data.
I think I found a slightly better workaround:
Before registering my real data, I just do:
Code: Select all
foreach (var dataSource in _stiReport.DataSources)
{
_stiReport.RegData(((StiDataSource) dataSource).Alias, new object[] {});
}
So I can be sure each datasource is at least initialized with an empty list (and the connected databand will then auto-hide).
I still think, the original behaviour is a bug. I'll send a sample to support.
Missing data sources
Posted: Thu Nov 11, 2010 6:48 am
by Alex K.
Hello,
Ok. Thank you.