Hi everyone, I’m trying to format a string to paste it in a cell that accepts an object, I’m doing the data parsing and formatting in the beforePaste event, but I don’t know why it doesn’t work despite the data is been parsed. Code below:
`beforePaste: (data, coords) => {
// data -> [[1, 2, 3], [4, 5, 6]]
const columns = [];
const formattedData = [];
// using nextTick because coords[0].startCol and coords[0].endCol always returns 0
this.$nextTick(() => {
// get all paste data columns using the start and end col values from coords
for (
let index = coords[0].startCol;
index <= coords[0].endCol;
index++
) {
columns.push(index);
}
// loop through all data and format data based on column
let rowIndex = 0;
for (const row of data) {
// row: [value, value]
let rowItemIndex = 0;
// go through row item and parse data based on column
// rowItemIndex will match the column index in columns array
for (const value of row) {
const columnIndex = columns[rowItemIndex];
if (columnIndex === this.findColumnHeaderIndex("location")) {
// check if paste data is string or an object with code, and name
// if its string, find the country object (code, name)
const isStringCheck = isString(value);
if (isStringCheck) {
const country = findCountry(value);
row.splice(rowItemIndex, 1, {
name: country.name,
code: country.code,
});
data.splice(rowIndex, 1, row);
console.log(country, data);
}
}
// console.log(rowIndex, value, columnIndex, data);
rowItemIndex++;
}
rowIndex++;
}
return data;
});
},`
Using Vue 2 and “handsontable”: “^12.1.2”