3
A
回答
4
請與下面的代碼片段嘗試所有頁面導出。
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Kendo UI Snippet</title>
<link rel="stylesheet" href="http://cdn.kendostatic.com/2014.3.1119/styles/kendo.common.min.css">
<link rel="stylesheet" href="http://cdn.kendostatic.com/2014.3.1119/styles/kendo.rtl.min.css">
<link rel="stylesheet" href="http://cdn.kendostatic.com/2014.3.1119/styles/kendo.default.min.css">
<link rel="stylesheet" href="http://cdn.kendostatic.com/2014.3.1119/styles/kendo.dataviz.min.css">
<link rel="stylesheet" href="http://cdn.kendostatic.com/2014.3.1119/styles/kendo.dataviz.default.min.css">
<link rel="stylesheet" href="http://cdn.kendostatic.com/2014.3.1119/styles/kendo.mobile.all.min.css">
<script src="http://code.jquery.com/jquery-1.9.1.min.js"></script>
<script src="http://cdn.kendostatic.com/2014.3.1119/js/jszip.min.js"></script>
<script src="http://cdn.kendostatic.com/2014.3.1119/js/kendo.all.min.js"></script>
<style>
#products .k-grid-toolbar
{
display:none !important;
}
</style>
</head>
<body>
<button id="export" class="k-button"><span class="k-icon k-i-excel"></span>Export to Excel</button>
<div id="products"></div>
<div id="orders"></div>
<script>
// used to sync the exports
var promises = [
$.Deferred(),
$.Deferred()
];
$("#export").click(function(e){
// trigger export of the products grid
$("#products").data("kendoGrid").saveAsExcel();
// trigger export of the orders grid
$("#orders").data("kendoGrid").saveAsExcel();
// wait for both exports to finish
$.when.apply(null, promises)
.then(function(productsWorkbook, ordersWorkbook) {
// create a new workbook using the sheets of the products and orders workbooks
var sheets = [
productsWorkbook.sheets[0],
ordersWorkbook.sheets[0]
];
sheets[0].title = "Products";
sheets[1].title = "Orders";
var workbook = new kendo.ooxml.Workbook({
sheets: sheets
});
// save the new workbook,b
kendo.saveAs({
dataURI: workbook.toDataURL(),
fileName: "ProductsAndOrders.xlsx"
})
});
});
$("#products").kendoGrid({
toolbar: ["excel"],
excel: {
allPages: true
},
dataSource: {
transport: {
read: {
url: "http://demos.telerik.com/kendo-ui/service/Products",
dataType: "jsonp"
}
},
pageSize: 20
},
height: 550,
pageable: true,
excelExport: function(e) {
e.preventDefault();
promises[0].resolve(e.workbook);
}
});
$("#orders").kendoGrid({
dataSource: {
type: "odata",
transport: {
read: "http://demos.telerik.com/kendo-ui/service/Northwind.svc/Orders"
},
pageSize: 20,
serverPaging: true
},
height: 550,
pageable: true,
columns: [
{ field:"OrderID" },
{ field: "ShipName", title: "Ship Name" },
{ field: "ShipCity", title: "Ship City" }
],
excelExport: function(e) {
e.preventDefault();
promises[1].resolve(e.workbook);
}
});
</script>
</body>
</html>
讓我知道是否有任何問題。
相關問題
- 1. 劍道UI角2格Excel導出
- 2. 劍道UI格 - Excel導出隱藏列和自定義格式
- 3. 劍道UI網格結合
- 4. 劍道UI網格保存
- 5. 劍道UI電網
- 6. 劍道UI角度網格 - 高度
- 7. 劍道UI網格,計算列
- 8. 劍道UI網格錯誤事件
- 9. 劍道UI網格 - PHP的serversides分頁
- 10. 劍道UI網格顯示的翻譯:
- 11. 選擇的DataItem在劍道UI網格
- 12. 劍道UI MVC網格行選擇
- 13. 劍道UI - 工具提示在網格
- 14. 劍道UI網格模板列
- 15. 劍道網格與多個數據源
- 16. 劍道UI電網出現故障
- 17. 無法將劍道網格數據導出到Excel電子表格
- 18. 我改變了劍道UI網格列標題,但對出口的Excel
- 19. 訴諸劍道UI電網
- 20. 劍道UI電網ClientTemplate
- 21. 下拉劍道UI電網
- 22. 劍道UI電網的OData
- 23. 填寫劍道UI電網
- 24. 劍道網格sortingI
- 25. 劍道UI格屬性
- 26. 劍道網格自定義導航
- 27. 未能從劍道電網大數據導出到Excel
- 28. 劍道UI網格按鈕觸發多時間
- 29. 劍道網格輸出爲帶邊框的Excel
- 30. 劍道網格導出爲excel並隱藏excel中的幾列
它的工作原理,謝謝。但是,如果我編輯我的網格然後更新,它只是導出舊數據不是新的。 – Vincent
你能否提供你的代碼片段? –
這是我的代碼,謝謝你的幫助。 [鏈接](http://stackoverflow.com/questions/27663647/how-to-export-kendo-multiple-grid-after-grid-refresh-display-new-datas) – Vincent