Can not format data before paste

Tags: #<Tag:0x00007efc728ccec0> #<Tag:0x00007efc728ccd80>

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”

Hi @ikhidebright

Thank you for contacting us. I wanted to check your code but it seems that there are some missing variables. Would it be possible for you to prepare a simplified code demo showing the issue?

Hi, thanks for your reply. Its a large codebase and i will be unable to create a demo sorry, but i am simply trying to format the paste data before paste happens.

Hi @ikhidebright

I think that the problem here might be related to the issue that we are currently work on. As you are trying to convert data type to object with a dot inside the object key this might be the cause, as for now, we don’t allow it. We are researching the issue and soon we should have more info about how we will resolve it. I’ll update you then.