0
votes

I want to generate Excel after clicking a custom button(not export button) from Kendo grid and Save the file.

Pls Help me.

1
What have you tried so far? Do you want the user to choose where to save it? - David Shorthose

1 Answers

1
votes

You can have a custom button in the grid

.ToolBar(tools =>
                {                       
                    tools.Custom().Text("Export to Excel").HtmlAttributes(new { @class = "exporTtoExcelClass" });
            })

And on the grid bound function you need to add function

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;
     });
}