Hello,
I can perform various operations when adding rows using the addRow method. However, sometimes I use copy-paste to add multiple rows, and in this case, the addRow method is not triggered.
I tried using the beforePaste event, but it executes for all rows, including the existing ones that are not newly added.
What I need is an event that triggers only when a new row is added to the grid, whether through addRow or paste functionality. Is there something like a beforeRowAdd event or any alternative to achieve this?
This function "GridNew()" assigns default values to new rows.
I use it to add new rows and set default values for them, but it does not work for rows added via paste.
The goal is to make it work for rows added through paste as well.
window.GridNew = function () {
function applyDefaultValues(rowData) {
var defaultValues = { type: 1, code: 'newCode',quantity:1 };
return Object.assign({}, defaultValues, rowData);
}
// Adding a new row
var newRowData = applyDefaultValues({}); // Apply default values
if (localStorage.getItem('qpRowBottom') == 1) {
// Adding a new row at the bottom
var pm = grid.option("pageModel");
grid.option("pageModel", { type: 'local', curPage: 1, rPP: pm.rPP, rPPOptions: pm.rPPOptions });
var rowIndx = grid.addRow({
newRow: newRowData,
track: true,
history: false,
checkEditable: false,
refresh: true
});
console.log("New row added: Bottom");
grid.goToPage({ rowIndx: rowIndx });
grid.editFirstCellInRow({ rowIndx: rowIndx });
} else {
// Adding a new row at the top
var rowIndx = grid.addRow({
rowIndxPage: 0,
newRow: newRowData,
track: true,
history: false,
checkEditable: false,
refresh: true
});
console.log("New row added: Top");
grid.editFirstCellInRow({ rowIndx: rowIndx });
}
};
Thank you for your help!