Вопрос

I set up my reporting page so that it all just rendered out and had no problems at all, everything worked dandy :).

Now the problem comes when I want to render the report when the Run Report button is clicked. This still renders fine, but the toolbar and viewer are not hooked up properly. When I click any of the page navigation buttons (Not the "Go To beginning/end ones) I get a NaN error from the current page index. Now this stuff is auto generated when the report viewer partial is rendered, and as the toolbar is already rendered it seems to have a problem picking it up. Here is my index and ajax call for your reference to see if anyone can help.

<h2>Basic Error Report</h2>
@Html.Partial("_BasicErrorReportFilters")

<input type="button" value="RunReport" id="runReportBtn" onclick="RunReport()"/>
@Html.DevExpress().ReportToolbar(settings =>
    {
        settings.Name = "ReportViewerToolbar";
        settings.ReportViewerName = "reportViewer1";
    }).GetHtml()
<div id="reportDiv"></div>

Ajax Call:

$.ajax({
            type: "POST",
            url: '@Url.Action("ReportViewerPartial", "BasicError")',
            data: queryString,
            statusCode: {
                200: function (r) {

                    $('#reportDiv').html(r);
                    var dxo = new ClientReportToolbar('ReportViewerToolbar');
                    window['ReportViewerToolbar'] = dxo;
                    dxo.menuID = 'ReportViewerToolbar_Menu';
                    dxo.reportViewerID = 'reportViewer1';

                    dxo.InlineInitialize();

                },
                400: function(r) {

                },
                500: function(r) {

                }
            }
        });

    }

You'll see that I am re initializing the toolbar in the javascript. Before I put that in, the toolbar would not pick up the viewer at all.

Funilly, once I have had the NaN error, I can use the go to beginning and end buttons properly, and once I have used one of those, all of the navigation/export/print buttons work fine. Thanks in advance for any help.

Cheers

Это было полезно?

Решение

I found the issue.

It seems that when reinitializing, having this bunch of code:

 var dxo = new ClientReportToolbar('ReportViewerToolbar');
                    window['ReportViewerToolbar'] = dxo;
                    dxo.menuID = 'ReportViewerToolbar_Menu';
                    dxo.reportViewerID = 'reportViewer1';

In that code block doesn't work, but moving it outside of that block and just having dxo.initialize in there does.

Cheers

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top