Hi,
On my page I have a Grid with edit mode set to batch. I want to print the grid and include any edited data that was entered by the user.
Is this possible?
|
function onClick() {
var gridObj = document.getElementById('Grid').ej2_instances;
gridObj.editModule.batchSave();
} |
I understand. Thank you.
I tried using the BeforePrint function to execute editeModule.batchSave(), but this requires a user to first click OK or Cancel before the data is saved.
Should I rather use a different edit mode to achieve my requirements? Or is there a way to automatically accept that changes are going to be saved to the Grid datasource without requiring the user to either accept or decline?
|
EditSettings(edit => { edit.AllowEditing(true) … .Mode(Syncfusion.EJ2.Grids.EditMode.Batch).ShowConfirmDialog(false); }) |
|
// Global flag condition is enabled by default
var isInitial = true;
// Grid’s BeforePrint event handler
function onBeforePrint(args) {
var gridObj = document.getElementById('Grid').ej2_instances[0];
// Check if batch changes are available
var isAdd = (gridObj.getBatchChanges().addedRecords.length !== 0) ? true : false;
var isEdit = (gridObj.getBatchChanges().changedRecords.length !== 0) ? true : false;
var isDelete = (gridObj.getBatchChanges().deletedRecords.length !== 0) ? true : false;
if (isInitial && (isAdd || isEdit || isDelete)) {
// Condition executes for initial print action if batch changes are available
// Initial print action is cancelled
args.cancel = true;
// Global flag condition is disabled so that this condition is not executed when print action is called below
isInitial = false;
// Batch changes are saved to the Grid
gridObj.editModule.batchSave();
// Print action is executed with the updated Grid data
gridObj.print();
}
}
// Grid’s PrintComplete event handler
function onPrintComplete() {
// Global flag condition is enabled so that these actions can be performed for concurrent print
isInitial = true;
} |