Pass additional arguments to @save event handler of the QPopupEdit
Hi! I have QPopupEdit that is used to edit a value “in place” a cell in a QTable.
<q-table :columns="columns" :visible-columns="visibleColumns" row-key="name" :data="ds">
.......
<q-tr slot="body" slot-scope="props" :props="props">
<q-td v-for="col in props.cols" :key="col.name" :props="props">
.......
<template v-else-if="col.classes === 'popup-edit'">
{{ col.value }}
<q-popup-edit v-model="props.row[col.field]" @save="UpdateDocument">
</q-popup-edit>
</template>
</q-td>
</q-tr>
.......
</q-table>
After submit QPopupEdit i would like to send request for update the document. For this action i need documentId and some fields, wich stored in row of QTable, but handler UpdateDocument receive only "val" and "initialValue". If I will write <q-popup-edit v-model="props.row[col.field]" @save="UpdateDocument(props.row)"> then i can send update request, but in case of update error can not restore old value of table cell. How pass additional arguments into @save handler? For example @save="UpdateDocument(val, initialValue, props.row) Like problem discussed in https://forum.quasar-framework.org/topic/2725/qpopupedit-how-to-pass-own-argument
@sontis3
yep would be nice to do that, solution for now is add a unique ref on your q-popup-edit and pass it as argument in one of its events in your case on-save like so @save="UpdateDocument($event, $ref[myUniqueRef].initialValue, props.row). the $event is the new value, @save="UpdateDocument($ref[myUniqueRef], props.row) instead and process the ref's value / initialValue in the called method. I guess you can file a request for feature about this.
You can use <q-popup-edit :value="props.row[col.field]" @input="val => UpdateDocument(col.field, val)">.
Build further from here.
@pdanpdan, thanks.
In my case solution is
<q-popup-edit :value="props.row[col.field]" @save="(val, initialValue) => UpdateDocument(val, initialValue, props.row)">
Arrow function helped to solve the problem of additional arguments.
good to know there are other ways, i don't like ref way much, specially if it's from something out of a loop.
感谢 已解决 神奇的quasar
Translation: "Thanks resolved magical quasar"