HTML 5 Viewer Error with AllowNull and MultiValue

7 posts, 0 answers
  1. Mike
    Mike avatar
    11 posts
    Member since:
    Feb 2015

    Posted 08 Nov 2018 Link to this post

    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.

     

     

  2. Mike
    Mike avatar
    11 posts
    Member since:
    Feb 2015

    Posted 08 Nov 2018 in reply to Mike Link to this post

    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');
            }
        }
    });
  3. Todor
    Admin
    Todor avatar
    248 posts

    Posted 13 Nov 2018 Link to this post

    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
  4. Mike
    Mike avatar
    11 posts
    Member since:
    Feb 2015

    Posted 06 Dec 2018 in reply to Todor Link to this post

    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

     

  5. Mike
    Mike avatar
    11 posts
    Member since:
    Feb 2015

    Posted 06 Dec 2018 Link to this post

    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.
  6. Todor
    Admin
    Todor avatar
    248 posts

    Posted 11 Dec 2018 Link to this post

    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
  7. Todor
    Admin
    Todor avatar
    248 posts

    Posted 11 Dec 2018 Link to this post

    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
Back to Top