Page 1 of 1
Report Variable problem
Posted: Wed Mar 04, 2009 5:10 am
by srini_morapaka
I have created/designed a report with two report variables (Ex. Company and Trn.Date) and these two report variables are placed on to the report. I saved the report
template in the sql server database(express). When i view the report by passing two report variables, i get correct report. But if i pass one variable (ie. Trn.Date), i am
getting the report with two variables. Trn.Date is correct, because i passed it to the report. But company is showing the value, which i had passed it at the time of report
creation. I don't want see the variable, which i did not pass to the report. Either i should delete the variable which was not passed or i should hide variable when i view the report.
It should be handled at runtime for that i have to develop logic for this. I tried to inspect the report variables in the Dictionary using StiVariable, but i am not able to delete or hide the variable.
Please provide me the sample code in c#.
thanks in advance.
Report Variable problem
Posted: Wed Mar 04, 2009 9:17 am
by Edward
Hi,
You can delete a variable from the Dictionary only in the report template before compilation, when report is just a set of objects. It is impossible to delete variable when the report has been loaded from assembly, compiled or attached as class in the Application.
The code for deleting of the Variable is simple:
report.Dictionary.Variables.Remove("VariableName");
Thank you.
Report Variable problem
Posted: Wed Mar 04, 2009 10:30 pm
by srini_morapaka
Edward wrote:Hi,
You can delete a variable from the Dictionary only in the report template before compilation, when report is just a set of objects. It is impossible to delete variable when the report has been loaded from assembly, compiled or attached as class in the Application.
The code for deleting of the Variable is simple:
report.Dictionary.Variables.Remove("VariableName");
Thank you.
Thanks for your reply. I am able to delete the variable from the Dictionary. But, is there any solution for not to display the report variable on the report, which was not passed to the report.
Thank you.
Report Variable problem
Posted: Thu Mar 05, 2009 2:36 pm
by Jan
Hello,
You want remove variables from report dictionary if it does not have value before calling report designer?
Thank you.
Report Variable problem
Posted: Thu Mar 05, 2009 10:17 pm
by srini_morapaka
Jan wrote:Hello,
You want remove variables from report dictionary if it does not have value before calling report designer?
Thank you.
Not from report dictionary, I am able to delete variables from report dictionary. I want to delete variables from report design if it does not have value before calling report designer.
Thank you.
Report Variable problem
Posted: Fri Mar 06, 2009 2:03 am
by Edward
Hello
There is a Nullable type of variables in the Dictionary. If you do not assign such variables, their result would remain as null.
There is also a HideZeroes property in the StiText component.
If you need to modify expression or hide entire StiText component or to change somehow the expression of the report components, then you should use the following loop:
Code: Select all
StiReport report = new StiReport();
report.Load("report.mrt");
foreach (StiComponent comp in report.GetComponents())
{
if (comp is StiText)
{
StiText myText = (comp as StiText);
{
if (myText.Text.Value.Contains("MyVariable"))
{
myText.Enabled = false;
}
}
}
}
report.Show();
Thank you.
Report Variable problem
Posted: Fri Mar 06, 2009 4:22 am
by srini_morapaka
Edward wrote:Hello
There is a Nullable type of variables in the Dictionary. If you do not assign such variables, their result would remain as null.
There is also a HideZeroes property in the StiText component.
If you need to modify expression or hide entire StiText component or to change somehow the expression of the report components, then you should use the following loop:
Code: Select all
StiReport report = new StiReport();
report.Load("report.mrt");
foreach (StiComponent comp in report.GetComponents())
{
if (comp is StiText)
{
StiText myText = (comp as StiText);
{
if (myText.Text.Value.Contains("MyVariable"))
{
myText.Enabled = false;
}
}
}
}
report.Show();
Thank you.
Thank you very much.
it solved my problem.
Report Variable problem
Posted: Fri Mar 06, 2009 5:40 am
by Edward
Hi
You are welcome!
Please let us know if we could assist you any further.
Thank you.