Kendo UI 网格导出到 Excel 不工作

Kendo UI Grid export to Excel not working

我遇到过类似的问题,为什么我的 excel 导出按钮不起作用? 它有什么问题。感谢您的帮助。

$("#grid").kendoGrid({
  toolbar: ["create", "excel", "pdf"],
  excel: {
      fileName: "Test.xlsx",
        allPages: true
    },
  columns: [
    { field: "name" },
    { field: "age" }
  ],
  dataSource: {
    data: [
      { id: 1, name: "Jane Doe", age: 30 },
      { id: 2, name: "John Doe", age: 33},
    ],
    schema: {
      model: { id: "id" }
    }
  },
  editable: true
});
.k-grid-toolbar {
    display: flex;
    flex-direction: row;
    justify-content: flex-start;
    align-items: center;
}

.k-grid-toolbar .k-grid-excel {
    margin-left: auto;
}
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8"/>
    <title>Kendo UI Snippet</title>

    <link rel="stylesheet" href="https://kendo.cdn.telerik.com/2019.1.220/styles/kendo.common.min.css"/>
    <link rel="stylesheet" href="https://kendo.cdn.telerik.com/2019.1.220/styles/kendo.rtl.min.css"/>
    <link rel="stylesheet" href="https://kendo.cdn.telerik.com/2019.1.220/styles/kendo.silver.min.css"/>
    <link rel="stylesheet" href="https://kendo.cdn.telerik.com/2019.1.220/styles/kendo.mobile.all.min.css"/>

    <script src="https://code.jquery.com/jquery-1.12.4.min.js"></script>
    <script src="https://kendo.cdn.telerik.com/2019.1.220/js/kendo.all.min.js"></script>
  

</head>
<body>
  
<div id="grid"></div>

</body>
</html>

如果您检查过浏览器的控制台,您会发现 Kendo 遗漏了一些库。 "To take full advantage of the Excel export feature, download the JSZip library and include the file before the Kendo UI JavaScript files, as shown" 这里:https://docs.telerik.com/kendo-ui/framework/excel/introduction#requirements

试试这个:

 toolbar: ["excel"],
        excel: {
            fileName: "Excel File Name.xlsx",
            filterable: true,
            allPages: true
        },