Preventing excel export does not work
eyupyusein opened this issue · 0 comments
Description
Kendo UI for jQuery version 2024.2.514 (2024 Q2) appears to have introduced a new feature that shows a loading / progress overlay on the grid when you click the Export button.
Something we do in our grids is call e.preventDefault() if there is no data to export and the button is clicked. That appears to be the recommended approach to prevent an export based on the documentation here: https://docs.telerik.com/kendo-ui/api/javascript/ui/grid/events/excelexport
While e.preventDefault() does prevent the export, the loading / progress overlay remains on the grid. Furthermore, simply hiding it with JS (e.g. grid.loader.hide() or grid.loaderOverlay.hide()) makes it go away, but the grid is in an unresponsive state (e.g. you can't sort rows or click Export again).
Workaround
You can use the following alternative solution which disables the Export Excel button depending on a condition:
<script>
function dataBound(e){
if(true){ // data is 0
$(".k-grid-excel").addClass("k-disabled");
}
}
</script>
Here is a live sample for demonstration:
https://netcorerepl.telerik.com/myFlPxcv57G9CLP123