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

Select first option in param

2 Answers 211 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Justin Lee
Top achievements
Rank 1
Justin Lee asked on 22 Jul 2011, 10:42 PM
Hello.  I have a report with 2 params.  The datasource of the second param uses the selected value of the first param. 
Example:    Param 1 is a list of car manufactures, and Param 2 is a list of Models for the selected car manufacture.

I have set this up, and it is working correctly.  However, what I would like to do is have Param 2 automatically select the first option after the user selects from Param1.
Example:  User chooses "Ford", and "Mustang" is automatically selected in Param 2 (because its the first in the list), and the Mustang report is displayed.  (Currently, after selecting from Param1, the dropdown for Param2 says "<select a value>")

How can I accomplish this?

Thanks,
Justin

2 Answers, 1 is accepted

Sort by
0
Accepted
Steve
Telerik team
answered on 26 Jul 2011, 10:22 AM
Hi Justin Lee,

Unfortunately this is currently not possible as the depending parameter (the one that would refresh based on the main parameter) is evaluated only once. We would revisit the implementation and see what was the reason for this behavior and change it if applicable so that such scenario can be executed.

Sorry for the temporary inconvenience.

Greetings,
Steve
the Telerik team

Register for the Q2 2011 What's New Webinar Week. Mark your calendar for the week starting July 18th and book your seat for a walk through of all the exciting stuff we will ship with the new release!

0
Patrick
Top achievements
Rank 1
answered on 01 Aug 2011, 11:46 PM
What we've had to do was to create a UI page, be it a web page or a windows form, that collected all the search criteria. In your example, that would be querying the user for the make and model of the car. All your logic is in that page/form. Such as selecting the first model of the selected car make. When the user clicks a button to view the report, create an instance of the appropriate report, set it's parameters in code and display the report. For example, I have a form that contains two dropdown lists. The first contains the names of the reports, hardcoded at this time. The second dropdown list contains the search criteria applicable to the report selected in the first. I'm using the SelectedIndexChanged() event handler of the first list to populate the second. In the Click() event handler of the button that displays the selected report, I have:

private void btnRunReport_Click(object sender, EventArgs e)
{
  int selectedIndex = this.cboReports.SelectedIndex;
  // if the report viewer is already bound to a report...
  if (this.reportViewer1.Report != null)
  {
    // release it
    this.reportViewer1.Report = null;
    this.reportViewer1.RefreshReport();
  }
  switch (selectedIndex)
  {
    case 0:   // General Fund Check Register report
      // create an instance of the report associated with the selected index
      Telerik.Reporting.Report generalFundCheckRegister = new APVenders.Reports.GeneralFundCheckRegister();
      // set the "writtenDate" report parameter to what's selected in the report criteria combobox
      generalFundCheckRegister.ReportParameters["writtenDate"].Value = this.cboReportCriteria.Text;
      // bind the report to the report viewer
      this.reportViewer1.Report = generalFundCheckRegister; 
      // display the report
      this.reportViewer1.RefreshReport();
      break;
    case 1:   // Monthly Check/Void Register report  
      Telerik.Reporting.Report monthlyCheckVoidRegister = new APVenders.Reports.MonthlyCheckVoidRegister();
      monthlyCheckVoidRegister.ReportParameters["accountingPeriod"].Value = this.cboReportCriteria.Text;
      this.reportViewer1.Report = monthlyCheckVoidRegister;
      this.reportViewer1.RefreshReport();
      break;
  }
 
}

That's probably not the answer you wanted, but it's one way to workaround the limitation your bumping up against. Hope that helps...
Tags
General Discussions
Asked by
Justin Lee
Top achievements
Rank 1
Answers by
Steve
Telerik team
Patrick
Top achievements
Rank 1
Share this question
or