Page 1 of 1

Help creating Databand filter at run-time

Posted: Sun Nov 29, 2009 4:14 pm
by fuhrj
In my report, I have a drop-down list with a list of employees plus an option "All Users". Because of the "All" option, I can't hardcode the filter in the Databand so I am trying to create a filter at runtime.


In the report form, I have a button with an onclick event:

Code: Select all


if (userID > 0) {
	StiFilter userFilter = new StiFilter("ReportData.userID == " + userID.ToString());
	Data1.Filters.Add(userFilter);	
}

ReportData.Connect();


Help creating Databand filter at run-time

Posted: Sun Nov 29, 2009 5:22 pm
by fuhrj
Okay, I figured a way to make this work.

I created a variable to hold the value of the list item selected in the form.

On the Databand, I created this filter expression:

Code: Select all

ReportData.userID == ((varUser == 0) ? ReportData.userID : varUser)
If the user chooses "All Users" then varUser is set to 0. The expression checks the value of varUser and if it is 0, it uses the current userID. So the expression becomes ReportData.userID == ReportData.userID which will always evaluate true and the record will be used.