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

add or remove record #14

Closed bellpetchpol closed 1 year ago

bellpetchpol commented 1 year ago
let rec = {
        id: 1,
        headerId: 1,
        itemNumber: 1,
        description: "description",
 }
this.jsondata.splice(0, 0, rec);

I try modified v-model data on runtime but it won't effect the grid both appending or removing

I also try $refs.newRecord and $ref.deleteRecords(0) both won't work either

I need to use v-if on the component then switch it's visibility to make it work like this

this.shouldShowDataGrid = false;
await setTimeout(async () => {
        this.shouldShowDataGrid = true;
}, 10);
cscan commented 1 year ago

Post your data section, I suspect your data defined wrongly

On Tue, 10 Jan 2023, 11:56 PM Tochsaporn Petchpol, @.***> wrote:

let rec = { id: 1, headerId: 1, itemNumber: 1, description: "description", } this.jsondata.splice(0, 0, rec);

I try modified v-model data on runtime but it won't effect the grid both appending or removing

I also try $refs.newRecord and $ref.deleteRecords(0) both won't work either

I need to use v-if on the component then switch it's visibility to make it work like this

this.shouldShowDataGrid = false; await setTimeout(async () => { this.shouldShowDataGrid = true; }, 10);

— Reply to this email directly, view it on GitHub https://github.com/cscan/vue3-excel-editor/issues/14, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAYSOF4WIOVP3Y62PKZOWTLWRWBCLANCNFSM6AAAAAATW7IUYU . You are receiving this because you are subscribed to this thread.Message ID: @.***>

bellpetchpol commented 1 year ago

Here my codesandbox https://codesandbox.io/s/vue3-excel-editor-data-not-reactive-vf9iou

you should select any cell and then try to press the add or remove button you will see that actual data is change not the data grid.

It seem when I manipulate jsondata it won't generate the $id field

bellpetchpol commented 1 year ago

Hello cscan I found temporary solution Here

addRow(){

      let rec = {
          user: "kl",
          name: "Kenny Linus",
          phone: "1-891-2345685",
          gender: "M",
          age: 29,
          birth: "1990-09-01",
        };
      this.jsondata.splice(this.currentRowPos + 1, 0, rec);
      let newJsonData = this.jsondata;
      this.jsondata = [...newJsonData];
    }

let newJsonData = this.jsondata; this.jsondata = [...newJsonData];

I just need to reiterate jsondata then the $id property will get generate