[英]Kendo UI grid export excel and pdf export, no file created
我正在嘗試使用excel導出創建一個kendo網格。 我的數據正好按照我的要求顯示,網格工作正常。 但是,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
和對於網格中的每一行使用這些對象的數組:
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"
我有最新版本的kendo,我正在加載jszip。 我在最新版本的chrome上運行它。 我已經嘗試了我能想到的這些代碼的各種變體,包括刪除我的模式,每次在回調中重新初始化kendo。
任何人都知道為什么這不起作用?
我可以找到的每個例子都讓它看起來非常簡單,只需創建網格並調用導出...所以我必須忽略一些東西。
我很感激任何有關這方面的想法。
謝謝。
我有一些以下的建議。
可能是因為缺少文件名。
這里添加了文件名的部分:
excel: {
allPages:true,
filterable:true,
fileName: "Kendo UI Grid Export.xlsx"
},
你可以看看這里: 網格Excel導出
這里是pdf: Grid Pdf Export
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.