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. Image for the cookie policy date
close icon
Starting in 2019, the Reporting control is no longer included in Essential Studio. If you're experiencing issues with the Syncfusion Reporting Platform, Report Viewer, Report Designer, or Report Writer, we recommend migrating to Bold Reports, our dedicated reporting platform.

Bold Reports offers a comprehensive suite of tools and features for all your reporting needs, and we will help you make a smooth transition from the discontinued control. Our support team at https://support.boldreports.com/ is here to assist you with any questions or difficulties you may encounter during the migration process.

We thank you for choosing Syncfusion and appreciate your understanding.

Modify headers in ejReportViewer

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



1 Reply

SR Soundara Rajan S Syncfusion Team October 29, 2015 10:48 AM UTC

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.

Loader.
Live Chat Icon For mobile
Up arrow icon