It's been somewhat of a struggle but I'm trying to capture the the filter applied to rows in my grid to set a header value in my excel export template. I can get the Search bar value but not the column filter.
My grid-
<ejs-grid id="Grid" dataSource="@Model.Package_Log" allowExcelExport="true" toolbarClick="toolbarClick" dataBound="dataBound" width="1193"
toolbar="@(new List<string>() { "ExcelExport","ColumnChooser","Search" })"
showColumnChooser="true"
allowPaging="true" allowSorting="true" allowResizing="true" allowFiltering="true" allowGrouping="false" showColumnMenu="true">
<e-grid-filterSettings type="Menu" showFilterBarStatus="true" operators="@( new { stringOperator = @Model.operators})"></e-grid-filterSettings>
<e-grid-pagesettings pageCount="20" pageSize="14"></e-grid-pagesettings>
<e-grid-selectionsettings type="Multiple"></e-grid-selectionsettings>
<e-grid-columns>
<e-grid-column headerText="Package Name" field="PackageName" textAlign="Left"></e-grid-column>
<e-grid-column headerText="Sequence" field="PackageSequence" textAlign="Left" visible="false"></e-grid-column>
<e-grid-column headerText="Sequence Start" field="SequenceStart" textAlign="Left" headerTemplate="#datetemplatestart" customFormat="@(new { type= "dateTime", format= "MM/dd/yyyy hh:mm:ss a" })"></e-grid-column>
<e-grid-column headerText="Sequence End" field="SequenceEnd" textAlign="Left" customFormat="@(new { type= "dateTime", format= "MM/dd/yyyy hh:mm:ss a" })"></e-grid-column>
<e-grid-column headerText="Log Entry" field="LogMessage" textAlign="Left"></e-grid-column>
<e-grid-column headerText="Time Stamp" field="LogTimeStamp" textAlign="Left" customFormat="@(new { type= "dateTime", format= "MM/dd/yyyy hh:mm:ss a" })" visible="false"></e-grid-column>
<e-grid-column headerText="Status" field="SequenceStatus" textAlign="Left" visible="false"></e-grid-column>
<e-grid-column headerText="Error Number" field="SequenceErrNumber" textAlign="Left" visible="false"></e-grid-column>
<e-grid-column headerText="Error" field="SequenceErrDesc" textAlign="Left" visible="false"></e-grid-column>
</e-grid-columns>
</ejs-grid>
And my excel header template - the Search Bar value comes through just fine... But I'm not sure how to get at the column filter value?:
<script>
function toolbarClick(args) {
var gridObj = document.getElementById("Grid").ej2_instances[0];
var searchval = document.getElementById("Grid_searchbar").value;
var filterval = document.getElementById("Grid_colmenu_Filter").value;
if (searchval == "" || searchval.length == 0 || searchval == null) {
searchval = "All Rows No Searched filter";
}
else
{
searchval = " Rows Searched on " + searchval;
}
if (filterval == "" || filterval.length == 0 || filterval == null) {
filterval = "All Rows No Filter";
}
else {
filterval = " Rows Filtered on " + filterval;
}
var excelExportProperties = {
includeHiddenColumn: true,
header: {
headerRows: 4,
rows: [
{ cells: [{ colSpan: 4, value: "SSIS Package Logs", style: { fontColor: '#C67878', fontSize: 20, hAlign: 'Center', bold: true, } }] },
{ cells: [{ colSpan: 4, value: "[From ssisCorePortal " + searchval + " " + filterval + "]", style: { fontColor: '#C67878', fontSize: 15, hAlign: 'Center', bold: true, } }] },
{ cells: [{ colSpan: 4, value: "Exported on: @DateTime.Now", style: { fontColor: '#C67878', fontSize: 15, hAlign: 'Center', bold: true, } }] },
]
},
footer: {
footerRows: 4,
rows: [
{ cells: [{ colSpan: 4, value: "Thank you for your business!", style: { hAlign: 'Center', bold: true } }] },
{ cells: [{ colSpan: 4, value: "!Visit Again!", style: { hAlign: 'Center', bold: true } }] }
]
}
};
if (args.item.id === 'Grid_excelexport') {
//gridObj.showSpinner();
gridObj.excelExport(excelExportProperties);
}
if (args.item.id == "Grid_pdfexport") {
//gridObj.showSpinner();
gridObj.pdfExport();
}
}