Search code examples
visual-studio-2017devextreme

DevExtreme JSZIP error onVisual Studio


I'm experiencing issues using Jszip for DevExtreme.

My DataGrid is the following:

Html.DevExtreme().DataGrid()
                            .ID("testgrid")
                            .FilterRow(filter => {
                                filter.ApplyFilter(GridApplyFilterMode.Auto);
                                filter.Visible(true);
                            })
                            .Columns(columns =>{
                                //column definition
                            })
                            .OnCellPrepared("OnCellPrepared")
                            .OnCellClick("OnCellClick")
                            .ShowBorders(true)
                            .RowAlternationEnabled(true)
                            .ShowRowLines(true)
                            .ShowColumnLines(true)
                            .Export(e =>e.Enabled(true).FileName("export"))

But when I click on the export button I get this error:

Error: E1041 - The JSZip script is referenced after DevExtreme scripts. See: http://js.devexpress.com/error/17_2/E1041

I've checked my imports in my DevExtremeBundleConfig.cs, and Jszip.js is imported way before dx.all.

Here's the class:

public class DevExtremeBundleConfig {

    public static void RegisterBundles(BundleCollection bundles) {

        var scriptBundle = new ScriptBundle("~/Scripts/DevExtremeBundle");
        var styleBundle = new StyleBundle("~/Content/DevExtremeBundle");

        // CLDR scripts
        scriptBundle
            .Include("~/Scripts/jszip.js")
            .Include("~/Scripts/cldr.js")
            .Include("~/Scripts/cldr/event.js")
            .Include("~/Scripts/cldr/supplemental.js")
            .Include("~/Scripts/cldr/unresolved.js");

        // Globalize 1.x
        scriptBundle
            .Include("~/Scripts/globalize.js")
            .Include("~/Scripts/globalize/message.js")
            .Include("~/Scripts/globalize/number.js")
            .Include("~/Scripts/globalize/currency.js")
            .Include("~/Scripts/globalize/date.js");

        // jQuery
        //scriptBundle
        //    .Include("~/Scripts/jquery-2.2.3.js");

        //JSZip for client side export

        //scriptBundle
        //    .Include("~/Scripts/jszip.js");

        // DevExtreme + extensions
        scriptBundle
            .Include("~/Scripts/dx.all.js")
            .Include("~/Scripts/aspnet/dx.aspnet.data.js")
            .Include("~/Scripts/aspnet/dx.aspnet.mvc.js");

        // dxVectorMap data (http://js.devexpress.com/Documentation/Guide/Data_Visualization/VectorMap/Providing_Data/#Data_for_Areas)
        //scriptBundle
        //    .Include("~/Scripts/vectormap-data/africa.js")
        //    .Include("~/Scripts/vectormap-data/canada.js")
        //    .Include("~/Scripts/vectormap-data/eurasia.js")
        //    .Include("~/Scripts/vectormap-data/europe.js")
        //    .Include("~/Scripts/vectormap-data/usa.js")
        //    .Include("~/Scripts/vectormap-data/world.js");

        // DevExtreme
        // NOTE: see the available theme list here: http://js.devexpress.com/Documentation/Guide/Themes/Predefined_Themes/                    
        styleBundle
            .Include("~/Content/dx.common.css")
            .Include("~/Content/dx.light.css");


        bundles.Add(scriptBundle);
        bundles.Add(styleBundle);

#if !DEBUG
        BundleTable.EnableOptimizations = true;
#endif
    }
}

I'm using Visual Studio 2017, I've cleaned my project (from Visual Studio) and recompiled, but no luck at all.

What am I doing wrong?


Solution

  • Here you show your bundle config but I wonder how your rendered page looks. Also how your Layout page looks.

    In any case be sure when calling the bundles the order is correct and just to be sure test with direct references in a sample cshtml with no Layout.