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

HTML 5 Viewer Error with AllowNull and MultiValue

6 Answers 146 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Mike
Top achievements
Rank 1
Mike asked on 08 Nov 2018, 11:41 PM

Hello,

I searched the forums but was unable to find the issues that are similar to mine.  Recently  we updated to a newer version of Telerik Reporting(12.2.18.1017).  Either way when loading one of our old reports into the viewer or first loading it within the design which updates it to the new trdx model and saving. Then loading in the HTML 5 viewer. There seems to be a bug with HTML 5 Viewer when using parameters that are AllowNull and MultiValue together. In my case the lists are bound to a data source.  Upon clicking an option in one of my lists.  An API call is triggered for "parameters".  Any list that where AllowNull and MultiValue by default will have a value of null. So if you look at the ajax call to parameters(via developer tools in Chrome) you will see the following in the JSON request object. 

MyList: [null]

It is correctly passing that over as an array.  However, because null is the value selected .  This causes an error on the response such as

InnerException":{"Message":"An error has occurred.","ExceptionMessage":"No corresponding available value for value , parameter MyList","ExceptionType":"System.Exception","StackTrace":"   at Telerik.Reporting.Processing.Parameter.GetSingleLabel(Object value)\r\n   at Telerik.Reporting.Processing.Parameter.get_Label()\r\n   at GetLabel(Object )\r\n   at Newtonsoft.Json.Serialization.DynamicValueProvider.GetValue(Object target)"}}}

However, if before I click on a value in my first list that causes the call to the API.  If I choose a value within the AllowNull/MultiValue list and unselect it again.  This time when I click on the first list that triggers the API call the parameter is omitted from the JSON which basically means nothing is selected and there is no exception.  I tried many solutions without luck.  I tried using jQuery to find the elements after load and trigger click on all first elements twice to select/unselect them but this does not work. Triggering click does nothing.  Is there anyway via the report viewer data object($('#report-viewer').data("telerik_ReportViewer")) to force these lists to clear their values so that [null] is not passed?  This did not happen in our old version(~2016) in the WinForms viewer.  There the list would show as a disabled drop down with a checkbox to the right of it named "Null" that was checked.

 

 

6 Answers, 1 is accepted

Sort by
0
Mike
Top achievements
Rank 1
answered on 09 Nov 2018, 12:07 AM

Not ideal but it works on load. Still looking for better solutions though. I noticed that Clear selection sets the list to empty array.  that is passed to the API call without errors in the response.

$('div[id="trv-parameter-editor-multiselect-list"]').each(function (index) {
    var selected = $('div.trv-listviewitem.k-state-selected', $(this));
    if (selected.length == 0) {
        var clearLink = $(this).parent().find('.trv-select-none');
 
        if (clearLink.length) {
            clearLink.trigger('click');
        }
    }
});
0
Todor
Telerik team
answered on 13 Nov 2018, 11:25 AM
Hi Mike,

Thank you for reporting the issue.
This is a known bug introduced with Telerik Reporting R3 2018 SP1 (12.2.18.1017). It has been fixed in our latest Internal Build - Telerik Reporting R3 2018 SP2 (12.2.18.1109) - Nullable MultiValue Parameter with Value NULL generates array with one element. You may consider an update.

Regards,
Todor
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
Mike
Top achievements
Rank 1
answered on 06 Dec 2018, 08:49 PM

Hey Todor.  I updated to the most recent version of reporting at the time 12.2.18.1109.  Updating does fix the issue there.  However, when you click refresh it appears the same error is happening. The outer exception was

"The 'ObjectContent`1' type failed to serialize the response body for content type 'application/json; charset=utf-8'."

The outer exception led me to the following link.  I did not think this was the issue because I was already on 9.0.1. 

https://docs.telerik.com/reporting/knowledge-base/error-after-update-to-r2-2018-due-to-old-newtonsoft-json-version

After looking closer at the response.  I looked in the inner exception and saw. 

"No corresponding available value for value , parameter MyList"

Then I looked at my request and the empty list parameter(MyList) was getting passed over to the API as [null].  So it appears to be the same issue. Just this time it happens when you click refresh

 

0
Mike
Top achievements
Rank 1
answered on 06 Dec 2018, 09:00 PM
I can confirm my previous post.  If I click the "Clear Selection" link for all of my lists.  Then click refresh.  The report refreshes correctly.  So until there is a solution from Telerik I will have to use the Javascript code I mentioned in a previous comment to trigger the Clear Selection click for all my lists.
0
Todor
Telerik team
answered on 11 Dec 2018, 01:44 PM
Hi Mike,

I tested the described scenario locally and confirm the it reproduces on our end with the latest version of Telerik Reporting (12.2.18.1129). Upon clicking the "Clear Selection" button, the report receives an array with a single element, i.e. {object[0]}. I confirm that the issue is not related to Newtonsoft version.
We consider this as a bug in the Html5 Report Viewer JavaScript and have logged it for improvement. The previous bug was related to report serialization, hence this is actually another bug. As a token of gratitude for revealing the problem we have updated your Telerik points.
Until we fix the bug the custom JavaScript code would indeed be the suitable workaround.

Regards,
Todor
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
Steve
Top achievements
Rank 2
Iron
commented on 06 Mar 2024, 03:17 PM | edited

Hi Todor,

Can you link bug item for the HTML5 Viewer "empty array after 'Clear Selection'" bug please?

This is still present in 18.0.24.130

This is not so much a problem if using a `Parameters.myMultiValParam.Value.Length = 0` check should be fine - but:

  • the issue is not consistent behaviour, e.g. the standalone editor will not proceed with a preview while both the options list options is cleared and the "null" checkbox is unchecked (not that adding a "NULL" checkbox to the web viewer parameter editor is wanted particularly either)... one cant really test an empty multi-value parameter there
  • there doesnt appear to be great support for "empty" lists/IEnumerables (I dont think you can use Array() for an empty list/collection object? Might be ok to continue to fallback to NULL or a default like Array(0), depending on parameter usage in expressions for datasources etc).

Maybe a function like "IsNullOrEmpty()" could be useful - though similar to "IsNull()" with a default option, rather than String.IsNullOrEmpty().

Todor
Telerik team
commented on 11 Mar 2024, 11:37 AM

Hi Steve,

Thank you for raising this issue again. Indeed, when you trigger the 'Clear selection' button of the HTML5 Report Viewer parameter's area, there is no request for a report document with the updated parameter values and the viewer shows the previous report waiting for the user to select them. This occurs with both Single and MultiValue parameters that are non-nullable. In the Standalone designer and desktop viewers, the viewer displays a message indicating that the user needs to select valid parameter values.

I logged a bug report on your behalf - The Non-Nullable Parameters don't respect the cleared selection from the Html5 Viewer. As a token of gratitude, I updated also your Telerik points.

For the checks for Null or empty, generally, you may use the Comparison operators, for example 'IS NULL', and Aggregate Functions, for example, 'CountDistinct(Expression)' or 'Count(Expression)'. This cannot be applied to the AvailableValues property though.

Steve
Top achievements
Rank 2
Iron
commented on 11 Mar 2024, 01:04 PM | edited

Hi Todor,

Thanks for looking at this. I'm wondering if we have strayed from the "nullable"/"AllowNull" multi-value issue - thought its great if another related issue is identified and logged.

Also, Im not sure a request for a report document with updated parameters is needed, unless "AutoRefresh" is True - or maybe required to refresh the default value or reset dependant parameters.

In our case, clicking "clear selection" in the HTML5 Report Viewer appears to be reasonable in the viewer - showing an "empty" selection (which we often use as a state to not filter report data on that item, similar to an "all"/"any" selection). But then, when continuing with the new parameter selection (including the cleared Nullable multi-value parameter) and clicking "Preview", an empty array is submitted. This feels different to a nullable single-value parameter, where a NULL is submitted after a "clear selection" is used.

This caught us out, as we only checked for NULLs in expressions on parameters before attempting to use the value and the empty parameter collection/array value gave unexpected report results.

Todor
Telerik team
commented on 14 Mar 2024, 09:02 AM

Hello Steve,

Thank you for sharing your experience and thoughts on the problem.

Indeed, when AutoRefresh is False, there won't be an automatic request as the viewer would wait for the user to click the Preview button.

When a developer starts working on the problem, he/she will take into account all the information in the thread. Afterwards the QA would test all the described scenarios, ensuring a proper fix.

0
Todor
Telerik team
answered on 11 Dec 2018, 03:05 PM
Hi Mike,

Just to clarify, "Clear Selection" button click currently returns an empty array, *not* an array with one element. If the "Clear Selection" button is not clicked, the value will be Null after Refreshing the viewer, i.e. as the initial value.
I was not able to reproduce the error "The 'ObjectContent`1' type failed to serialize the response body for content type 'application/json; charset=utf-8'." after clicking on Refresh button of the viewer or the browser.
In the custom code "Null" value and empty array value may be handled in the same way (together) as they both indicate that there is no value chosen by the user.

Regards,
Todor
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
Tags
General Discussions
Asked by
Mike
Top achievements
Rank 1
Answers by
Mike
Top achievements
Rank 1
Todor
Telerik team
Share this question
or