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

From/To Date Parameters

8 Answers 276 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Derek
Top achievements
Rank 1
Derek asked on 23 May 2017, 08:22 AM

I have a report which uses From and To dates to retrieve data from the server. I created a datasource called dsDate which has a list of the distinct dates in the reporting table and also a dataset called dsReportData which gets the report data using the from/to parameters. My from/to report parameters both use dsDate as their data source, the default value for To is the most recent date and the default value for From is the 4th most recent date. In order to do this, I created a custom function called FromDate() which returns the correct from date.

This works great for the first load however if I change the From/To date report parameter then Telerik goes away to the server, gets the new dataset and then resets all the parameters so the From/To report parameters are then reset back to their default values rather than the value entered by the user. The correct dataset is being reported to the user however because the From/To date report parameters reset the users think that the report is showing the wrong data.

 

Any advice would be greatly appreciated.

 

I have attached several screenshots to help illustrate my problem -

  1. prmFrom shows the From Date Report Parameter
  2. prmTo shows the To Date Report Parameter
  3. ReportViewer1 shows parameters on initial load (Mar-17 - Mar-17)
  4. ReportViewer2 shows the changed parameter values (Jan-17 - Mar17)
  5. ReportViewer3 shows the parameters after the new dataset has beeb drawn (Mar-17 - Mar-17 rather than Jan-17 - Mar-17)

8 Answers, 1 is accepted

Sort by
0
Stef
Telerik team
answered on 25 May 2017, 04:40 PM
Hi Derek,

Change the Value properties of parameters to depend on other parameters instead of fields - cascading parameters. Thus changing one parameter will affect the value of other parameter. If you refresh the report or if you update the parameters values, parameters will not lose their selected values.


I hope this helps.

Regards,
Stef
Progress Telerik
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
0
Derek
Top achievements
Rank 1
answered on 13 Jun 2017, 08:50 AM

Hi Stef,

Thanks for your reply. My report is already set up as you advised. In the process of double checking it was set up correctly I noticed that the report parameters are working as expected through the visual studio designer preview but not through the html5 report viewer. The problematic parameters are set up to use the Custom Single Select Editor (http://docs.telerik.com/reporting/html5-webforms-report-viewer-customizing-custom-parameter-editor), it appears that they are being reset after a partial postback. 

How would I get them to retain their value?

function createSingleSelectEditor(placeholder, options) {
                var dropDownElement = $(placeholder).html('<div></div>');
                var parameter,
                      valueChangedCallback = options.parameterChanged,
                      dropDownList;

                function onChange() {
                    var val = dropDownList.value();
                    valueChangedCallback(parameter, val);
                }

                return {
                    beginEdit: function (param) {

                        parameter = param;

                        $(dropDownElement).kendoDropDownList({
                            dataTextField: "name",
                            dataValueField: "value",
                            value: parameter.value,
                            dataSource: parameter.availableValues,
                            change: onChange
                        });

                        dropDownList = $(dropDownElement).data("kendoDropDownList");
                    }
                };
            }

0
Stef
Telerik team
answered on 15 Jun 2017, 04:25 PM
Hi Derek,

Please compare your settings to these of the attached demo project. The project uses the latest Telerik Reporting R2 2017 SP1 and the default Kendo UI version used by the HTML5 Viewer.

Note that both report parameters should receive a valid value that exists in their AvailableValues.DataSource. The AvailableValues of the second report parameters in SampleReport.trdp are filtered based on the first parameter.


Regards,
Stef
Progress Telerik
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
0
Derek
Top achievements
Rank 1
answered on 16 Jun 2017, 10:36 AM

Hi Stef,

Thank you for the example project. I can confirm that this project is exhibiting the same behaviour as my own, please see the attached gif.

Any advice would be greatly appreciated.
0
Derek
Top achievements
Rank 1
answered on 16 Jun 2017, 10:37 AM
Attached to this post...
0
Derek
Top achievements
Rank 1
answered on 16 Jun 2017, 10:41 AM

The forum gives an error 500 when trying to upload a gif (see attached) so I have uploaded the gif here instead - http://imgur.com/a/h5VXK

Thanks.

0
Accepted
Stef
Telerik team
answered on 19 Jun 2017, 02:36 PM
Hello Derek,

The issue is in the DateTime values comparison. Editors are reset as the check if the selected value is in the AvailableValues fails. The comparison fails due to the different format of the DateTime values created at the client and the ones returned by the server as AvailableValues. if you switch to String report parameters, which you will have to convert later at places parameters are used, the issue will not be present. In reports you can use the built-in Text and Date functions and/or custom functions to cast the parameters' values.

Other approaches include to detect in what format is the selected value at the client in order to cast it to DateTime object

Regards,
Stef
Progress Telerik
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
0
Derek
Top achievements
Rank 1
answered on 23 Jun 2017, 10:58 AM

Hi Stef,

Your suggestion fixed my problem.

Thanks!

Tags
General Discussions
Asked by
Derek
Top achievements
Rank 1
Answers by
Stef
Telerik team
Derek
Top achievements
Rank 1
Share this question
or