Closed vincent-lu closed 3 years ago
Thank you for reporting this. Due to changes in v-model
behavior the syntax required is different:
<v-client-table :columns="columns" :data="data" @input="e=>data=e"></v-client-table>
I have also added it to the breaking changes section on the docs: https://matanya.gitbook.io/vue-tables-2/installation/vue-version-3#breaking-changes
Please also pull the latest (0.3.2) as I have added update
and input
to the list of emitted events on the client table
Hey thanks @matfish2 making some progress, but still some trouble.
This is my code:
<template>
<v-client-table
:data="table.data"
:columns="table.columns"
:options="table.options"
@input="(e) => (table.data = e)"
>
<template #[`post.title`]="{ row, update }"> // Had to use this syntax because the column contains dot
<input
v-model="row.post.title" // This sets the post.title value to this <input> correctly
type="text"
@update:modelValue="update" // This triggers update successfully
/>
</template>
</v-client-table>
</template>
<script>
import { reactive } from "vue";
export default {
const table = reactive({
data: [
{
id: 1,
name: "John",
post: {
title: "Foo bar",
},
},
{
id: 2,
name: "Tom",
post: {
title: "Hello world",
},
},
],
columns: ["id", "name", "post.title"],
options: {
editableColumns: ["post.title"],
},
});
return {
table,
};
};
</script>
The code above render the table successfully, with the post.title
field being rendered as a <input>
with correct value.
However, since the row data contains nested object post
, when I update the <input>
cell, the event
value in @input="(e) => (table.data = e)"
actually return this json:
{
"id": 1,
"name": "John",
"post": {
"title": "Foo bar",
},
"post.title": "New input"
},
Customising @input="(e) => (table.data = e)"
can solve this problem but it doesn't seem ideal, ideally the scoped update
function should understand we are trying to update the nested object value.
Let me know what you think @matfish2.
I have added nested data support on version 0.3.3. Should work now
Thanks @matfish2 confirmed working
Just thought to reopen this to ask about the update
event on <v-client-table>
@matfish2. Following my previous example code, I added @update="updateTable"
to the <v-client-table>
, so it becomes the following:
<v-client-table
:data="table.data"
:columns="table.columns"
:options="table.options"
@input="(e) => (table.data = e)"
@update="updateTable"
>
My updateTable simply just output the payload from the event, interestingly, I find that the payload is something like this when I type "helloworld" to the <input>
:
{
"column": "post.title",
"newVal": undefined,
"oldVal": "helloworld",
"row": {...}
}
Basically, the newVal
is always undefined
, and oldVal
always show the current typed value.
Perhaps there is something wrong with my configuration, or there is a bug in the updateValue
function?
Fixed in 0.3.4.
Thanks again @matfish2, confirmed fixed.
vue-tables-3
and VueJS 3, if I load the table with<v-client-table :data="table.data" ...>
it works fine, but when I swap:data
withv-model
(to implement Editable Cells) the table breaks with the above error message.BTW does Editable Cells feature work on
vue-tables-3
/vue3
?Many thanks.