I have a Vuetify Datatable
with inline editing using <v-edit-dialog>
components.
The Calories column values are numbers, but when I edit them, they are converted to strings by default and I want them to stay as numbers. For example If I change Frozen Yogurt Calories from 159 to 30, the value becomes the string "30".
Code Snippet
<td>
<v-edit-dialog
:return-value.sync="props.item.calories"
lazy
@save="save"
> {{ props.item.calories }}
<v-text-field
type="number"
slot="input"
v-model.number="props.item.calories"
label="Edit"
single-line
></v-text-field>
</v-edit-dialog>
</td>
I thought that using v-model.number
and the type=number
would solve the problem, but it's still happening.
This is a pen where you can reproduce my issue:
https://codepen.io/jdash99/pen/dQJVwx?editors=1010
v-model.number
changes it to number correctly, but something else changes it back to string, probably .sync
modifier.
Remove .sync
modifier from :return-value.sync
and it should work.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With