Hi, team.
I had no problems to implement the Grid control at any point, but I do not know what happens in the export of the data. According
to the documentation, a "Script" section must be included, in which the
toolbarClick function is called and AllowExporting must be enabled for
each case in the control declaration. The buttons are displayed without problems, but nothing happens when I press them.
I
must say that, looking for the Grid from the console and calling its
methods pdfExport() and excelExport(), the files are generated without
problems.
My code is the following:
<div>
@Html.EJS().Grid("ParticipantsGrid").AllowFiltering().AllowExcelExport().AllowPdfExport().Columns(col =>
{
col.Field("Id").HeaderText("ID").IsPrimaryKey(true).Width("120").Add();
col.Field("Identity").HeaderText("Número").Width("150").Add();
col.Field("AttendeeName").HeaderText("Nombres").Width("150").Add();
col.Field("AttendeeLastName").HeaderText("Apellidos").Width("150").Add();
col.Field("TypeParticipant").AllowEditing(false).HeaderText("Tipo").Width("150").Add();
col.Field("AttendeePosition").HeaderText("Cargo").Width("150").Add();
col.Field("AttendeeFaculty").HeaderText("Facultad").Width("150").Add();
col.Field("PaymentType").AllowEditing(false).HeaderText("Método de pago").Width("150").Add();
col.Field("Amount").HeaderText("Monto").Format("C2").Width("150").Add();
}).AllowPaging().AllowSorting().AllowGrouping().AllowReordering().AllowResizing().EditSettings(edit =>
{ edit.AllowDeleting(true).AllowEditing(true).Mode(Syncfusion.EJ2.Grids.EditMode.Dialog).ShowDeleteConfirmDialog(true);
}).FilterSettings(filter => {
filter.Type(Syncfusion.EJ2.Grids.FilterType.Excel);
}).PageSettings(page => page.PageSize(10)).Toolbar(new List<string>() { "Edit", "Delete", "Cancel", "Search", "PdfExport", "ExcelExport" }).Render()
</div>
<script>
function toolbarClick(args) {
var gridObj = document.getElementById("ParticipantsGrid").ej2_instances[0];
if (args.item.id === 'Grid_pdfexport') {
gridObj.pdfExport();
}
if (args.item.id === 'Grid_excelexport') {
gridObj.excelExport();
}
}
</script>