cscan / vue3-excel-editor

Vue3 plugin for displaying and editing the array-of-object in Excel style.
MIT License
231 stars 51 forks source link

Error with Add Column functionality #21

Closed nidhik157 closed 5 months ago

nidhik157 commented 1 year ago
runtime-core.esm-bundler.js:220 Uncaught TypeError: Failed to execute 'getComputedStyle' on 'Window': parameter 1 is not of type 'Element'.
    at getStyleVal (VueExcelEditor.vue:1512:16)
    at Proxy.colSepMouseDown (VueExcelEditor.vue:1519:11)
    at _createElementVNode.onMousedown._cache.<computed>._cache.<computed> (VueExcelEditor.vue:59:33)

[Screencast from 05-02-23 07:03:13 PM IST.webm](https://user-images.githubusercontent.com/42907447/216822215-ecd54f49-405c-4fdf-8f32-dd317c9c4ed6.webm)
nidhik157 commented 1 year ago

Screenshot from 2023-02-05 19-05-44

nidhik157 commented 1 year ago

@cscan FYI. This happens when I click on the add button for adding a new column

cscan commented 1 year ago

Currently no simple method provided to add or delete columns. However, I have codes in adding new column by recreating the fields variable. Let me look around ....

cscan commented 5 months ago

You may try the register hook:

<vue-excel-editor ref="editor" v-model="table" :register="regColumn" />

data () {
   return {
      table: []
   }
}
methods: {
   doImport () {
      this.$refs.editor.reset()
      this.table = [
         {columnA: 1, columnB: 992},
         {columnA: 2, columnB: 993},
         {columnA: 3, columnB: 994},
         {columnA: 4, columnB: 999}
      ],
   },
   regColumn (field, pos) {
      if (field.name === 'columnA') {
         field.header = 'Column A'
         field.width = '100px'
         field.dataType = 'NUMBER'
      }
      if (field.name === 'columnB') {
         field.header = 'Column B'
         field.width = '200px'
         field.dataType = 'NUMBER'
      }
   }
}