@Html.EJS().Grid("Grid")...EnableColumnVirtualization().EnableVirtualization().Height("500").AllowExcelExport(true)
.Columns(col =>
{
col.Field("OrderID").HeaderText("Order ID").IsPrimaryKey(true).Width("120").Add();
col.Field("CustomerID").HeaderText("Customer Name").Width("150").Add();
col.Field("EmployeeID").HeaderText("Customer Name").Width("150").Add();
...
}).Load("load").ExcelExportComplete("excelExportComplete").ToolbarClick("toolbarClick").Toolbar(new List<string>() { "ExcelExport" }).Render()
<script>
function toolbarClick(args) {
var gridObj = document.getElementById("Grid").ej2_instances[0];
if (args.item.id === 'Grid_excelexport') {
//Disable virtualization before calling excel export method
gridObj.enableColumnVirtualization = false;
gridObj.enableVirtualization = false;
gridObj.excelExport();
}
}
function excelExportComplete(args) {
//Enable the virtualization here
this.enableColumnVirtualization = true;
this.enableVirtualization = true;
}
...
</script>
|