We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy.
Unfortunately, activation email could not send to your email. Please try again.

Modify headers in ejReportViewer

Thread ID:

Created:

Updated:

Platform:

Replies:

120942 Oct 28,2015 04:51 PM Oct 29,2015 06:48 AM JavaScript 1
loading
Tags: ejReportViewer
Jon Christensen
Asked On October 28, 2015 04:51 PM

I followed this thread to modify the headers in ejReportViewer:  https://www.syncfusion.com/forums/119064/can-ejreportviewers-post-header-be-modified.   The PostReportAction worked fine the first time but the second time it failed on the second line, proxy.data is undefined:

            var proxy = $('#viewer')
            var proxyData = proxy.data('ejReportViewer');

If I remove my required header from the API and not override the doAjaxPost the report works fine and calls PostReportAction 6 times total.  I've got the doAjaxPost within an angular controller if that matters.

Here is my code:

        <div style="height: 650px;width: 950px;min-height:404px;" id="viewer"></div>
        <script type="text/javascript">

        $(function () {
            $("#viewer").ejReportViewer({
                reportServiceUrl: "http://flexadmin.local-aon.com/api/Flex/APIReports",
                processingMode: ej.ReportViewer.ProcessingMode.Remote,
                reportLoaded: "onReportLoaded"
            });
        })

    </script>

ej.ReportViewer.prototype.doAjaxPost = function (type, url, jsondata, onSuccess) {
            var proxy = $('#viewer')
            var proxyData = proxy.data('ejReportViewer');
            var inVokemethod = onSuccess;
            $.ajax({
                type: type,
                url: url,
                crossDomain: true,
                contentType: 'application/json; charset=utf-8',
                dataType: 'json',
                data: jsondata,
                beforeSend: function (req) {
                    if (inVokemethod == "_getPageModel" || inVokemethod == "_getPreviewModel") {
                        if (!proxyData._isToolbarClick) {
                            proxyData._showloadingIndicator(true);
                        } else {
                            proxyData._showNavigationIndicator(true);
                        }
                    }
                    req.setRequestHeader('ejAuthenticationToken', proxyData._authenticationToken);
                    req.setRequestHeader('__RequestVerificationToken', vToken);
                },
                success: function (data) {
                    if (data && typeof (data.Data) != "undefined") {
                        data = data.Data;
                    }
                    if (typeof (data) == "string") {
                        if (data.indexOf("Sf_Exception") != -1) {
                            proxyData._renderExcpetion(inVokemethod + ":" + data);
                            return;
                        }
                    }
                    proxyData[inVokemethod](data);
                },
            });
        }



Soundara Rajan S [Syncfusion]
Replied On October 29, 2015 06:48 AM

Hi Jon,

Thanks for contacting Syncfusion support.

We are unable to reproduce the mentioned issue at our end and its working fine. The mentioned issue might have occurred due to accessing of DOM element (var proxy = $('#viewer')) before loading viewer tag in your application. So, please ensure the tag access after DOM element loaded completion. However, we have prepared a angular sample with AJAX override that can be downloaded from the below location,
http://www.syncfusion.com/downloads/support/forum/120942/ze/AngularDemo315102229.zip

Regards,
Soundara Rajan S.

CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.

;