Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] - Moving between tables does not work for binding data. #39

Open
aalopatin opened this issue Oct 29, 2019 · 3 comments
Open

[BUG] - Moving between tables does not work for binding data. #39

aalopatin opened this issue Oct 29, 2019 · 3 comments
Labels
bug Something isn't working confirmed need draft Need to think or work out a solution

Comments

@aalopatin
Copy link

Hello!

I've made movable tables.

Here is part of my template:

<b-row>
            <b-col cols="6">
              <vue-tabulator ref="allPeriods" v-model="allPeriods" :options="optionsAllPeriods"></vue-tabulator>
            </b-col>
            <b-col cols="6">
              <vue-tabulator id="selectedPeriods" ref="selectedPeriods"  v-model="selectedPeriods" :options="optionsSelectedPeriods"></vue-tabulator>
            </b-col>
          </b-row>

Here are options dor these tables:

allPeriods: [],
        selectedPeriods: [],
        optionsAllPeriods: {
            layout:"fitColumns",
            height: 400,
            movableRows: true,
            movableRowsConnectedTables: "#selectedPeriods",
            columns: [
              {rowHandle:true, formatter:"handle", headerSort:false, frozen:true, width:30, minWidth:30},
              {title:"Период", field:"id", headerSort: false},
              {title:"Начало", field:"startPeriod", sorter:"date", headerSortStartingDir:"desc", visible: false},
              {title:"Окончание", field:"endPeriod", sorter:"date",  headerSortStartingDir:"desc", visible: false},
              {title:"Тип периода", field:"type", sorter:"string", visible: false}
            ],
        },
        optionsSelectedPeriods: {
          layout:"fitColumns",
          height: 400,
          movableRows: true,
          movableRowsReceiver: "add",
          columns: [
            {rowHandle:true, formatter:"handle", headerSort:false, frozen:true, width:30, minWidth:30},
            {title:"Период", field:"id", validator:"unique"},
            {title:"Начало", field:"startPeriod", sorter:"date", visible: false},
            {title:"Окончание", field:"endPeriod", sorter:"date", visible: false},
            {title:"Тип периода", field:"type", sorter:"string", visible: false}
          ],
        },

When I move rows between tables they are shown in the receiver. But they aren't shown in data of Vue

image

@aalopatin aalopatin added bug Something isn't working waiting admin Waiting a admin interaction labels Oct 29, 2019
@angeliski
Copy link
Owner

Hey @aalopatin
That makes sense. The current implementation of the vue-tabulator only handles the v-model to creating the Tabulator instance.
As a workaround, you can use the movableRowsReceived callback to handle that data transition.

I will see how to fix that, let me know if you have any suggestions.

Thank for your issue report

See you
Rogerio

@angeliski angeliski added confirmed and removed waiting admin Waiting a admin interaction labels Oct 31, 2019
@aalopatin
Copy link
Author

Hey @angeliski
I install Tabulator Manually. I've found next:
Reactivity doesn't work:

  1. When a row moves between tables;
  2. When a row moves inside a table, even when I turned on reactivityData in tabulator options.

But if I look at tabulator instance:

this.tabulator.getData()

or when using your component:

this.$refs.tabulator.getInstance().getData()

All changes are present in the Data.

So I have solved these problems as follows:

  1. Moving between tables - I use movableRowsReceiver
movableRowsReceiver:(fromRow, toRow, fromTable)=>{
     this.receiverData.push(fromRow.getData())
},
  1. Moving inside table - I use rowMoved:
rowMoved:(row) => {
     this.receiverData = this.tabulatorReceiver.getData()
},

tabulatorReceiver is a holder of Tabulator (or instance in your component).

Maybe it will help you.

@aalopatin
Copy link
Author

I reworked the second example, right:

rowMoved:(row) => {
          let count = this.receiverData.length
          let newData = this.tabulatorReceiver.getData()
          this.receiverData.splice(0, count)
          newData.forEach((newRow)=>{
            this.receiverData.push(newRow)
          })
        },

@angeliski angeliski added the need draft Need to think or work out a solution label Oct 3, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working confirmed need draft Need to think or work out a solution
Projects
None yet
Development

No branches or pull requests

2 participants