Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/opencv/3.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
Kendo ui 单击“自定义”按钮后从剑道网格生成Excel_Kendo Ui_Kendo Asp.net Mvc - Fatal编程技术网

Kendo ui 单击“自定义”按钮后从剑道网格生成Excel

Kendo ui 单击“自定义”按钮后从剑道网格生成Excel,kendo-ui,kendo-asp.net-mvc,Kendo Ui,Kendo Asp.net Mvc,我想在从剑道网格中单击自定义按钮(不是导出按钮)并保存文件后生成Excel 请帮助我。您可以在网格中自定义按钮 .ToolBar(tools => { tools.Custom().Text("Export to Excel").HtmlAttributes(new { @class = "exporTtoExcelClass" }); }) 在网

我想在从剑道网格中单击自定义按钮(不是导出按钮)并保存文件后生成Excel


请帮助我。

您可以在网格中自定义按钮

.ToolBar(tools =>
                {                       
                    tools.Custom().Text("Export to Excel").HtmlAttributes(new { @class = "exporTtoExcelClass" });
            })
在网格绑定函数中,需要添加函数

function Grid_DataBound() {
      var grid = $('#YourGrid').data('kendoGrid');
      var exportButton = grid.element.find(".exporTtoExcelClass");
      exportButton.unbind("click");
      exportButton.on("click", function (args) {
            kendo.ui.progress($("#YourGrid"), true);
            var grid1 = $("#YourGrid").data("kendoGrid");
            grid1.saveAsExcel();
            kendo.ui.progress($("#YourGrid"), false);
           return false;
     });
}

到目前为止你试过什么?您想让用户选择保存它的位置吗?在
dataBound
事件上绑定事件时要小心,因为它可能会被多次调用,从而复制元素中的绑定。@DontVoteMeDown,感谢您的宝贵反馈/建议。我已经编辑了解决方案。感谢@Diptee的解决方案,它工作得很好,但我不想下载excel文件,而是想将其保存在应用程序级别的自定义文件夹中。