quasar icon indicating copy to clipboard operation
quasar copied to clipboard

[V1] Vuex data modification error in QTable

Open sontis3 opened this issue 7 years ago • 2 comments

Software version

Quasar: 1.0.0-beta.19 @quasar/app (v1+ only): 1.0.0-beta.20 OS: Windows_NT(10.0.17763) - win32/x64 Node: 10.5.0 NPM: 6.1.0 Browsers: Chrome

What did you get as the error?

I have QTable with data from Vuex store. Into slot 'body-cell-...' inserted QCheckbox with @input event handler. When I toggle checkbox I have error from vuex: [Vue warn]: Error in v-on handler: "TypeError: Cannot set property value of #<Object> which has only a getter" found in QCheckbox Code example:

<q-table ...  :data="ds">
...
  <template v-slot:body-cell-enabled="props">
    <q-td :props="props">
      <q-checkbox v-model="props.value" @input="(val) => UpdateDocument(val, props.row, props.col)"/>
    </q-td>
  </template>
...
</q-table>
...
computed: {
    ds: {
      get() { return this.$store.state.dsCountries;  },
      set(value) { this.$store.commit('setDsCountries', value); },
    },
  },
...
methods: {
    UpdateDocument(val, row, column) {...}

I found in the code of Quasars mixin checkbox.js method

toggle(e) {
 ...
 this.$emit('input', val)
}

Component QCheckbox update his model just before invoke my handler for event 'input' with vuex mutation data and generate error vuex. Similar problem exists for QPopupEdit. See https://forum.quasar-framework.org/topic/3410/qpopupedit-throws-error-in-callback-for-watcher-function

What were you expecting?

If the QTable has embedded QCheckbox and/or QPopupEdit and uses data from Vuex, then it is necessary to allow Vuex data mutations to be called. But I do not know how to do it right.

sontis3 avatar Apr 29 '19 14:04 sontis3

@sontis3 - As a general rule, instead of opening up an issue when you are uncertain, we'd rather have you use either the forum or the discord channel for your questions or to clear up uncertainty. If it turns out to be a bug, then we'll ask you to create an issue.

Thanks. 😄

If you are using @input, try using value and not v-model and make sure you update the value accordingly in your method, i.e. as in mutating it in your store. Please move the conversation to a thread in the forum or the discord channel. This issue will be closed (or do it yourself, once you've moved it over).

Thanks again! 😄

Scott

smolinari avatar Apr 29 '19 16:04 smolinari

Thanks, Scott. I try using value and it works. I agree that need to use the forum for such questions, but no one answered a similar question. And it was not clear wheter it was a bug or need to implement a feature.

sontis3 avatar Apr 30 '19 10:04 sontis3