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

Cascading Parameters with a default value

3 Answers 193 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Chris
Top achievements
Rank 2
Chris asked on 01 Aug 2011, 10:40 AM
Hi,
 I have a report that has two parameters the second is cascaded from the first, what I would like to do is to have the second parameter pick up the first value from it's available values after the collection has been populated.

For example parameter one is a list of user names and parameter two is a list of dates based on the username. I would like parameter two to have a value equal to the fist available date in it's available values collection each time that the user name is changed.

The reason for this is to allow the report to show the newest data when opened up so that the end user does not have to select a date unless they wish to view a different one.

Thanks

Chris

3 Answers, 1 is accepted

Sort by
0
Peter
Telerik team
answered on 04 Aug 2011, 11:38 AM
Hi Chris,

Currently the out of the box parameters don't offer such option. However such request is logged in our bug/feature tracking system. Thus we will introduce a way to select the first value with an expression in subsequent version of Telerik Reporting. 

In the meantime as a workaround our suggestion is to create custom UI for the parameters (for example using our Controls) and hook it up to the parameters via the Reporting API as shown in the following code snippets: 

protected void Page_Load(object sender, EventArgs e)
{
    var report1 = new Report1();
    report1.ReportParameters["MultiValueParameter1"].Value = new object[] { 1, 2 };
       report1.ReportParameters["Parameter1"].Value = "myValue";
    ReportViewer1.Report = report1;
}

Protected Sub Page_Load(sender As Object, e As EventArgs)
    Dim report1 = New Report1()
    report1.ReportParameters("MultiValueParameter1").Value = New Object() {1, 2}
   report1.ReportParameters("Parameter1").Value = "myString"
    ReportViewer1.Report = report1
End Sub
All the best,
Peter
the Telerik team

Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get now >>

0
Sergio
Top achievements
Rank 1
answered on 23 Nov 2011, 12:56 AM
Greetings

I have a very similar scenario.. The only difference is that the MultiSelect Parameter gets rendered based on user's last time - or last report ran (preference values are stored in the database when the NeedDataSource event gets called)

I actually did accomplish the above-mention successfully.. I used a custom Aggregate Function for this purpose.

[AggregateFunction(Description = "Get Graphs to Displays from a Database", Name = "GraphsDisplaySpecific")]
    public class GraphsDisplaysAggregateFunction : IAggregateFunction
    {
       ArrayList result;
        public void Accumulate(object[] values)
        {
            int value = Convert.ToInt16(values[0]);
            result = RMREPORT.MainConfigurator.Get_GraphListingArray(value); // where value is the account ID parameter
            // and static Get_GraphListingArray function obtains the Selected values stored in the database
        }
 
        public object GetValue()
        {
            return result;
        }
 
        public void Init()
        {
            this.result = new ArrayList();
        }
 
        public void Merge(IAggregateFunction aggregateFunction)
        {
            throw new NotImplementedException();
        }
    }


So what is my problem?.. The parameters are not giving me the cascading effect.. The Aggregate function works but It only works once!

When selecting an account from my first parameter, the Second Parameter (The MultiValue) render the desired selection. However, When I select a different account a second time, my aggregate function does not get executed. Or no apparent behavior of a postback..

Again, It produces the desire results but only once.

Do you have any guidance as of how can I produce the continuous effect of refreshing the second parameter after the first one have been selected?

Thanks
0
Peter
Telerik team
answered on 24 Nov 2011, 03:14 PM
Hi Sergio,

Generally by design the definition report parameters Value property is the default value. Thus it's expression is evaluated only once and the default value is preserved in the report definition.
The Report Parameter area provides out of the box UI support for the parameters that covers 98% of the user cases and for that reason it is not customizable. In order to achieve your requirement, you should create custom UI for the parameters (for example using our Controls) and hook it up to the parameters via the Reporting API as shown in the following code snippet:

var report1 = new Report1();
report1.ReportParameters["MultiValueParameter1"].Value = new object[] { 1, 2 };
report1.ReportParameters["Parameter1"].Value = "myValue";
ReportViewer1.Report = report1;

Greetings,
Peter
the Telerik team

Q3’11 of Telerik Reporting is available for download. Register for the What's New in Data Tools webinar to see what's new and get a chance to WIN A FREE LICENSE!

Tags
General Discussions
Asked by
Chris
Top achievements
Rank 2
Answers by
Peter
Telerik team
Sergio
Top achievements
Rank 1
Share this question
or