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

Parameter from array with needdatasource event

1 Answer 137 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
MGrassman
Top achievements
Rank 2
MGrassman asked on 14 Sep 2010, 05:54 AM
I have a report that I'm creating that I want the parameter to be from an array which I know how to do but when I try to set the

.AvailableValues.ValueMember the value isn't found because I'm using the needdatasource event to bind my business object to the datasouce.

Is there anyway this value doesn't need to be set?  I'm filtering myself in the needdatasource event and am not sure how to get this to work.

------------- Here is the code in the constructor.

InitializeComponent();
string[] groupTypes = new string[5] { "All", "Connect k & OnePlan", "NON WSA", "WSA", "Administrators" };

 

 

this.ReportParameters["UserGroups"].AvailableValues.DataSource = groupTypes;

 

 

this.ReportParameters["UserGroups"].AvailableValues.ValueMember = "=Fields.UserGroups";

 

 

------------- Need Datasource looks as follows

 

Inventory.Report.Properties.

Settings settings = new Inventory.Report.Properties.Settings();

 

 

DbUtils.ActualConnectionString = settings.InventoryConnectionString;

 

 

ActivityLogCollection data = new ActivityLogCollection();

 

 

SortExpression s = new SortExpression(new SortClause(ActivityLogFields.ActivityLogId, SortOperator.Descending));

 

 

PredicateExpression f = new PredicateExpression();

 

f.Add(

ActivityLogFields.ActivityLogType == 1);

 

 

if (this.ReportParameters["UserGroups"].Value != null && this.ReportParameters["UserGroups"].Value.ToString().Length > 0 && !this.ReportParameters["UserGroups"].Value.ToString().Equals("All"))

 

{

f.AddWithAnd(

new FieldLikePredicate(ActivityLogFields.UserGroups, null, "%" + this.ReportParameters["UserGroups"].Value + "%"));

 

}

data.GetMulti(f, -1, s);

(sender

as Telerik.Reporting.Processing.Report).DataSource = data;

 

 


Seems like I should just be able to specify a parameter even if the report doesn't have a fields associated to it?

Thanks,

1 Answer, 1 is accepted

Sort by
0
Steve
Telerik team
answered on 15 Sep 2010, 04:40 PM
Hello MGrassman,

If you're using an array, the ValueMember and DisplayMember would match, so the correct syntax is:

string[] groupTypes = new string[5] { "All", "Connect k & OnePlan", "NON WSA", "WSA", "Administrators" };
this.ReportParameters["UserGroups"].AvailableValues.DataSource = groupTypes;
this.ReportParameters["UserGroups"].AvailableValues.ValueMember = "=Fields.Item";


Sincerely yours,
Steve
the Telerik team
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 Public Issue Tracking system and vote to affect the priority of the items
Tags
General Discussions
Asked by
MGrassman
Top achievements
Rank 2
Answers by
Steve
Telerik team
Share this question
or