Parameter from array with needdatasource event

2 posts, 0 answers
  1. MGrassman
    MGrassman avatar
    92 posts
    Member since:
    Apr 2007

    Posted 14 Sep 2010 Link to this post

    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,

  2. Steve
    Admin
    Steve avatar
    10941 posts

    Posted 15 Sep 2010 Link to this post

    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
  3. DevCraft banner
Back to Top