<ejs-dialog id='dialog' header="Enter pdf file name" showCloseIcon="true" isModal="true" visible="false" width="300px" target="#Grid">
<e-content-template>
<div class='dialogContent'><input class="dialogText" /></div>
</e-content-template>
<e-dialog-buttons>
<e-dialog-dialogbutton buttonModel="@ViewBag.DialogButtons1" click="dlgButtonClick"></e-dialog-dialogbutton>
<e-dialog-dialogbutton buttonModel="@ViewBag.DialogButtons2" click="dlgButtonClick"></e-dialog-dialogbutton>
</e-dialog-buttons>
</ejs-dialog> |
// Grid’s toolbarClick event handler
function toolbarClick(args) {
if (args.item.id === 'Grid_pdfexport') {
// The rendered EJ2 Dialog is displayed if pdf export toolbar button is clicked
var dialogObj = document.getElementById('dialog').ej2_instances[0];
dialogObj.show();
}
} |
// Dialog button click handler
function dlgButtonClick(args) {
var gridObj = document.getElementById("Grid").ej2_instances[0];
var dialogObj = document.getElementById('dialog').ej2_instances[0];
if (args.target.innerText === "OK") {
// The input value is retrieved
var newName = args.target.closest('.e-dialog').querySelector('input').value;
// The input value is set as the file name for the pdf export
var exportProperties = {
fileName: newName + ".pdf"
};
// Pdf export from Grid
gridObj.pdfExport(exportProperties);
// Dialog is hidden
dialogObj.hide();
} else {
// Dialog is hidden
dialogObj.hide();
}
} |