Filtering by dynamic list when no selection is made

6 posts, 0 answers
  1. Al
    Al avatar
    203 posts
    Member since:
    Oct 2006

    Posted 12 Aug Link to this post

    Hi,
    I have a report that shows eg. Company and department names, I have built a filter by both of these to say

    Company in Company parameter
    and
    Department in Department parameter

    Where the Company and Department parameters are multi-value and are built from a datasource. Everything works just fine...as long as at least one company and department value are selected in the filter boxes ie. it is always filtering on these fields.

    How do I get the report to display everything when nothing is selected in the filter boxes?

  2. Katia
    Admin
    Katia avatar
    299 posts

    Posted 15 Aug Link to this post

    Hi Al,

    Set the default value for both parameters so if no value is set by the user the filters will be applied based on the parameters default values.

    To set multiple values(all values) as the default ones, set the parameters Value property to an IEnumerable instance  - check Specifying Default Values for a MultiValue Parameter for more detailed information.


    Regards,
    Katia
    Telerik by Progress
    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 Feedback Portal and vote to affect the priority of the items
  3. DevCraft banner
  4. Al
    Al avatar
    203 posts
    Member since:
    Oct 2006

    Posted 15 Aug in reply to Katia Link to this post

    Thanks Katia,

    I use the html viewer with a custom resolver to load trdp reports dynamically - how would I use that code in that scenario?

    I mean I know how to set parameters default values but how would I get the argument "Fields.MyField" to pass to AllValues(object[] values).

  5. Katia
    Admin
    Katia avatar
    299 posts

    Posted 15 Aug Link to this post

    Hi Al,

    In case, you need to set report parameters in custom resolver you can work directly with the report instance's ReportParameters collection, for example:
    Telerik.Reporting.Report report = new Report1();
    report.ReportParameters["Parameter1"].Value = "= AllValues(Fields.MyField)";

    Note, that TRDP report needs to be unpackaged first - Unpackaging.


    Regards,
    Katia
    Telerik by Progress
    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 Feedback Portal and vote to affect the priority of the items
  6. Al
    Al avatar
    203 posts
    Member since:
    Oct 2006

    Posted 15 Aug in reply to Al Link to this post

    Thanks Katia,

    I'll give that a bash but am pretty sure it will not work as per my post here:

    Setting Parameters at Runtime

     

  7. Al
    Al avatar
    203 posts
    Member since:
    Oct 2006

    Posted 16 Aug in reply to Al Link to this post

    Just some feedback - I have no clue what's going on here but here is my code that does indeed seem to set the default value for multi-value parameters to all available options in a custom resolver:

    Thanks Katia.

     

    ReportConnectionStringManager csm = new ReportConnectionStringManager(providerConnStr);
     
    var appPath = HttpContext.Current.Server.MapPath("~/");
    var reportsPath = Path.Combine(appPath, "Reports");
    var uri = Path.Combine(reportsPath, report);
     
    var sourceReportSource = new UriReportSource()  { Uri = uri };
     
    reportInstance = csm.UpdateReportSource(sourceReportSource);
     
    //Set parameters
    foreach (var reportParm in (reportInstance as InstanceReportSource).ReportDocument.ReportParameters)
    {
        if (reportParm.Name.ToLower() == "Department".ToLower())
        {
            reportParm.Value = "= AllValues(Fields.Department)";
        }
    }

Back to Top
DevCraft banner