IgbGridToolbarExporter の ExportStartedScript に指定した javascript ファンクションを使用し、引数よりファイル名にエクスポートの日時を追加することができます。
以下のように IgbGridToolbarExporter の ExportStartedScript に javascript ファンクション「onExportStartedScript」を指定します。
<IgbGrid .....>
<IgbGridToolbar>
<IgbGridToolbarActions>
<IgbGridToolbarExporter Filename="@fileName"
ExportStartedScript="onExportStartedScript">
</IgbGridToolbarExporter>
</IgbGridToolbarActions>
</IgbGridToolbar>
.....
</IgbGrid>
@code {
private string fileName = "MyExcel";
.....
}
onExportStartedScript を javascript で以下のように定義します。
igRegisterScript("onExportStartedScript", (ev) => {
//ファイル名に現在の日時情報を追加する
ev.detail.options.fileName =
ev.detail.options.fileName.replace(".xlsx", "").replace(".csv", "") +
"_" + new Date().toLocaleDateString('ja-JP') +
" " + new Date().toLocaleTimeString('ja-JP');
}, false);
以上の実装で、IgbGrid のツールバーからのエクスポート時に xlsx または csv ファイル名に現在の日時が追加されます。