I have on click function like:
<script type="text/x-kendo-template" id="template">
<div class="toolbar">
<button id="ExportExcel" class="btn btn-default " onclick="ExportExcel(); return false;"><i class="fa fa-file-excel-o"></i> Exportar</button>
</div>
</script>
Normally I call it as easy like:
function ExportExcel() {
$("#lstEmployees").data("kendoGrid").saveAsExcel(); // export grid to excel
}
And it works, but now I need to change my function and I have something like:
var exportFlag = false;
$("#lstEmployees").data("kendoGrid").bind("ExportExcel", function (e) {
if (!exportFlag) {
// e.sender.showColumn(0); for demo
// for your case show column that you want to see in export file
e.sender.showColumn(2);
e.preventDefault();
exportFlag = true;
setTimeout(function () {
e.sender.saveAsExcel();
});
} else {
e.sender.hideColumn(5);
e.sender.hideColumn(6);
exportFlag = false;
}
});
But I get issue:
Uncaught TypeError: Cannot read property 'bind' of undefined
What is wrong there? How can I call onclick Export excel as a function like work example? Regards