Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/logging/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 剑道UI网格导出excel和pdf导出,未创建任何文件_Javascript_Ajax_Kendo Ui_Kendo Grid - Fatal编程技术网

Javascript 剑道UI网格导出excel和pdf导出,未创建任何文件

Javascript 剑道UI网格导出excel和pdf导出,未创建任何文件,javascript,ajax,kendo-ui,kendo-grid,Javascript,Ajax,Kendo Ui,Kendo Grid,我正在尝试使用excel导出创建剑道网格。我的数据完全按照我的要求显示,网格运行良好。但是,saveAsExcel函数会触发excelExport事件,但不会创建任何文件。pdf导出也存在同样的问题。 以下是我的网格选项: grid = $("#grid").kendoGrid({ toolbar:["excel","pdf"], height: 500, scrollable: true, groupable: true,

我正在尝试使用excel导出创建剑道网格。我的数据完全按照我的要求显示,网格运行良好。但是,saveAsExcel函数会触发excelExport事件,但不会创建任何文件。pdf导出也存在同样的问题。 以下是我的网格选项:

grid = $("#grid").kendoGrid({
        toolbar:["excel","pdf"],
        height: 500,
        scrollable: true,
        groupable: true,
        sortable: true,
        filterable: false,
        excel: {
            allPages:true,
            filterable:true
        },
        excelExport: function(e) {
            console.log('Firing Export');
            console.log(e.workbook);
            console.log(e.data);
        },
        pdfExport: function(e){
            console.log('PDF export');

        },
        columns: [
            { field: "date", title: "Time", template: "#= kendo.toString(kendo.parseDate(date), 'MM/dd/yyyy') #", width: '120px'},
            { field: "customer", title: "Customer" },
            { field: "amount", title: "Total", format: "{0:c}", width: '70px', aggregates: ["sum"]},
            { field: "paid_with", title: "Payment", width: '130px'},
            { field: "source", title: "Source" },
            { field: "sale_location", title: "Sale Location" }
        ]
    }).data("kendoGrid");
只要数据的搜索参数发生更改,就会调用此ajax。我在这里刷新数据源

        $.ajax({
            'url':'/POS/ajax/loadTransactionsDetailsForDay.php',
            'data':{
                filters
            },
            'type':'GET',
            'dataType':'json',
            'success':function(response) {
                var dataSource = new kendo.data.DataSource({
                    data: response.data.invoices,
                    pageSize: 100000,
                    schema: {
                        model: {
                            fields: {
                                date: {type: "string"},
                                customer: { type: "string" },
                                amount: { type: "number" },
                                paid_with: {type: "string"},
                                source: {type:"string"},
                                sale_location: {type:"string" }
                            }
                        }
                    }
                });
                grid.setDataSource(dataSource);
                grid.refresh();
            }

        });
控制台日志的输出为

Firing Export.
工作表对象

Object {sheets: Array[1]}sheets: Array[1]0: Objectlength: 1__proto__: Array[0]__proto__: Object
对于网格中的每一行,使用以下对象进行and和array操作:

0: o
   _events: Object
   _handlers: Object
   amount: 40.45
   customer: "customer 1"
   date: "2015-11-25T00:00:00-08:00"
   dirty: false
   employee: 23
   paid_with: "Check"
   parent: ()
   sale_location: "Main"
   source: "POS"
   uid: "70b2ba9c-15f7-4ac3-bea5-f1f2e3c800d3"
我有最新版本的剑道,我正在加载jszip。我正在最新版本的chrome上运行它。 我尝试了我能想到的这段代码的各种变体,包括删除我的模式,每次在回调中重新初始化剑道

有人知道为什么这行不通吗

我能找到的每个例子都让它看起来超级简单,只需创建网格并调用导出。。。所以我一定是忽略了什么

我很感激你对这件事的任何想法


谢谢。

我有以下建议

  • 您可以添加剑道泄气pako脚本文件到您的代码,并尝试
  • 然后删除pdf导出事件,并尝试使用工具栏默认功能导出pdf。检查其是否工作
  • 尝试使用kendo传输技术和read方法在网格选项中添加数据源ajax调用
    可能是因为缺少文件名

    此处添加了文件名的部件:

    excel: {
            allPages:true,
            filterable:true,
            fileName: "Kendo UI Grid Export.xlsx"
        },
    
    您可以在这里查看:


    这里是pdf:

    您的实现似乎还可以。你确定jszip是在剑道之前加载的吗?我复制了你的javascript,它工作正常(有一个空文件)。这可能是权限问题吗?我的文件被写入我的下载文件夹。@thew_Black_Smurf是的,它是在下载之前加载的。我有一个时间限制,所以我最终写了一个网格的CSV导出。但我会回到这一点,并试图找出是什么原因造成的。我可以生成其他文件,而不是通过剑道。因此,我不认为这是一个许可错误。