first load with requirejs stimulsoft.reports.js crash

Stimulsoft Reports.JS discussion
Post Reply
negrero
Posts: 5
Joined: Mon Jun 12, 2017 2:39 pm

first load with requirejs stimulsoft.reports.js crash

Post by negrero »

When stimulsoft.reports.js is loaded for the first time, the application is broken but does not give any type of error, (with 2016 versions did not happen):
crashinforme.jpg
crashinforme.jpg (16.82 KiB) Viewed 1610 times

When I click on another menu option and click again on the report option the report appears loaded:
correctinforme.jpg
correctinforme.jpg (32.9 KiB) Viewed 1610 times
rconfig:

Code: Select all

paths:{
.....
     'reportjs-report': '../libs/stimulsoft.reports',
     'reportjs-viewer': '../libs/stimulsoft.viewer',
...
}
shim:{
     'reportjs-viewer': { deps: ['reportjs-report']},
     'reportjs-report': {deps: ['jquery']},
}
reportVierwer.js:

Code: Select all

define(['report.module','reportjs-viewer','reportjs-report' ], function(module, viewer, report){
    "use strict";

    module.registerDirective('reportViewer', ['$http', 'Context', function($http, Context) {
        return {
            restrict: "E",
            templateUrl: "app/custom/directives/reportviewer/report-viewer.tpl.html",
            //temaplate: '<div id="viewerContent" ></div>',
            controller : function(){                
            scope: {
                template: '='
            },
            link: function (scope, element, attr) {
                var template = undefined;
                //Stimulsoft.Base.StiLicense.key

                // Specify necessary options for the viewer
                var options = new Stimulsoft.Viewer.StiViewerOptions();
                if(localizationEs === undefined)
                    var localizationEs = null;

                //options.toolbar.showDesignButton = true;
                options.appearance.scrollbarsMode = true;
                options.toolbar.showFullScreenButton = false;

                //options.viewerId="viewerContent"
                options.height="1000px"
                //options.width="100%"
                options.appearance.chartRenderType = Stimulsoft.Report.Export.StiHtmlChartType.Vector;

                options.exports.showExportToWord2007 = false;
                options.exports.showExportToExcel2007 = false;

                options.toolbar.zoom = 75;
                options.toolbar.showZoomButton = false;


                // Create the report instance
                var viewer = new Stimulsoft.Viewer.StiViewer(options, "StiViewer", false);

                var refreshReport = function(datasource) {
                    // show process indicator
                    viewer.showProcessIndicator();

                    // load the report template from server
                    var report = new Stimulsoft.Report.StiReport();

                    //report.load(template);
                    template = (datasource.template !== undefined)
                        ? datasource.template
                        :scope.template;

                    //report.load(scope.template);
                    $http.get(template)
                        .success(function (data) {
                            if(datasource.Activities !== undefined)
                                for (var pages in data.Pages){
                                    for (var component in data.Pages[pages].Components){
                                        if(data.Pages[pages].Components[component].Area !== undefined){
                                            if(datasource.Activities[0] !== undefined)
                                                data.Pages[pages].Components[component].Area.XAxis.Title.Text = datasource.Activities[0].unit;
                                        }
                                    }
                                }
                            if(datasource.template !== undefined)
                                delete datasource.template;

                            report.load(data);

                            report.dictionary.databases.clear();

                            report.regData("InfractionsDataSet", "", datasource);

                            // merge presentation and data
                            report.render();

                            // Assign report to the viewer, the report will be built automatically after rendering the viewer
                            viewer.report = report;

                            // Render the viewer to selected element
                            viewer.renderHtml("viewerContent");

                            viewer.hideProcessIndicator();

                        })
                        .error(function (error) {
                            viewer.hideProcessIndicator();

                            console.log('Error loading report');
                        });

                }

                var cleanUpExecteReport = Context.subscribe(Context.EVENT_BUS().EXECUTE_REPORT, function(event, datasource) {
                    refreshReport(datasource);

                    /*
                    $http.get(datasource.template)
                        .success(function (data) {
                            template = data;
                            for (var pages in data.Pages){
                                for (var component in data.Pages[pages].Components){
                                    if(data.Pages[pages].Components[component].Area!==undefined){
                                        data.Pages[pages].Components[component].Area.XAxis.Title.Text = datasource.Activities[0].unit;
                                    }
                                }
                            }
                            delete datasource.template;
                            refreshReport(datasource);
                        })
                        .error(function (error) {
                            viewer.hideProcessIndicator();

                            console.log('Error loading report');
                        });
*/
                });

                /*
                $http.get(scope.template)
                    .success(function (data) {
                        template = data;

                        refreshReport({});
                    })
                    .error(function (error) {
                        viewer.hideProcessIndicator();

                        console.log('Error loading report');
                    });
                */
                refreshReport({})
                scope.$on('$destroy', function() {
                    cleanUpExecteReport();
                });
            }
        }
    }]);

    module.run(function($couchPotato) {
        module.lazy = $couchPotato;
    });

    return module;
});
Version 2017.1.4 stimulsoftjs
Alex K.
Posts: 6488
Joined: Thu Jul 29, 2010 2:37 am

Re: first load with requirejs stimulsoft.reports.js crash

Post by Alex K. »

Hello,

Could you please prepare a simple project which reproduces the issue and send us for analysis.

Thank you.
Post Reply