Ok, I have made some more progress. My grid is using beforeBatchAdd=checkForSelectedRow
That function looks like this:
function checkForSelectedRow(args) {
var grid = document.getElementById("Grid").ej2_instances[0];
var selectedRow = grid.getSelectedRecords()[0];
if (selectedRow === undefined) {
args.cancel = true;
bootbox.alert({
title: 'No record selected to copy from',
message: 'You must select a row that you would like to duplicate in order to add a new row. ' +
'The row you select will be used to determine which Action/ Objective you are creating a Status Update for and will populate the Division, Focus Area, Objective / Action, and FY fields. <br> <br>' +
'The Reporting Period, Status, and Comment fields will be editable. <br><br>' +
'The new row will appear at the top of the grid. After updating your changes, it will be sorted.',
centerVertical: true
});
}
else {
args.defaultData["ReporterObjectiveStatusUpdateFullDetail"]["ObjectiveId"] = selectedRow["ReporterObjectiveStatusUpdateFullDetail"]["ObjectiveId"];
args.defaultData["ReporterObjectiveStatusUpdateFullDetail"]["FiscalYearSortOrder"] = selectedRow["ReporterObjectiveStatusUpdateFullDetail"]["FiscalYearSortOrder"];
args.defaultData["ReporterObjectiveStatusUpdateFullDetail"]["StatusUpdateFiscalYearId"] = selectedRow["ReporterObjectiveStatusUpdateFullDetail"]["StatusUpdateFiscalYearId"];
args.defaultData["ReporterObjectiveStatusUpdateFullDetail"]["DivisionDescription"] = selectedRow["ReporterObjectiveStatusUpdateFullDetail"]["DivisionDescription"];
args.defaultData["ReporterObjectiveStatusUpdateFullDetail"]["AspectDescription"] = selectedRow["ReporterObjectiveStatusUpdateFullDetail"]["AspectDescription"];
args.defaultData["ReporterObjectiveStatusUpdateFullDetail"]["ObjectiveDescription"] = selectedRow["ReporterObjectiveStatusUpdateFullDetail"]["ObjectiveDescription"];
args.defaultData["ReporterObjectiveStatusUpdateFullDetail"]["StatusUpdateFiscalYearDescription"] = selectedRow["ReporterObjectiveStatusUpdateFullDetail"]["StatusUpdateFiscalYearDescription"];
args.defaultData["Champions"] = selectedRow["Champions"];
args.defaultData["Reporters"] = selectedRow["Reporters"];
args.defaultData["ReportingPeriods"] = selectedRow["ReportingPeriods"];
args.defaultData["Statuses"] = selectedRow["Statuses"];
}
}
So all that is missing is adding the new row underneath the selected row instead of at the top of the grid. Is this possible? I have tried args.index = x with no luck.