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 -
- prmFrom shows the From Date Report Parameter
- prmTo shows the To Date Report Parameter
- ReportViewer1 shows parameters on initial load (Mar-17 - Mar-17)
- ReportViewer2 shows the changed parameter values (Jan-17 - Mar17)
- 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
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

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");
}
};
}
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

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.

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.
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

Hi Stef,
Your suggestion fixed my problem.
Thanks!