-
Notifications
You must be signed in to change notification settings - Fork 149
Props updated on table-column does not updating table component #47
Comments
I think this is gonna be a necessary evil for the way this package is set up. I'll look into adding this later this week. The first snippet won't need to be that verbose though, you can pass an array to the created() {
this.$watch(['show', 'label', ...], () => {
this.$parent.$emit('columnUpdate');
});
}, |
Wow, thanks for the snippet. I don't know that I was thinking the columns can be somehow updated one by one instead of all columns, but since any props might be changed, it's difficlut to tracks which column has changed. The column might even been removed from or inserted into the table. so what really necessary is watching the changes of the I'm looking forward to the future update. Cheers, bro! |
First of all, sorry I lied 😅 I really thought I passed an array to Imo it's easier to just use a single change event. I see swapping columns as an edge case, so I don't think we should be optimizing too hard at this stage. I just released Here's the commit: 3c9aee8 |
My apologies for late comment, I found 2 issues on this commit 3c9aee8 columnComponents.forEach(column => {
Object.keys(this.$options.props).forEach(
prop => this.$watch(prop, () => this.mapColumns())
);
});
The mysterious thing is although it is watching incorrect props but it still works! async mounted() {
this.mapColumns();
await this.mapDataToRows();
+ this.$watch('data', () => this.mapColumns());
},
mapColumns() {
const columnComponents = this.$slots.default.filter(
column => column.componentInstance
);
this.columns = columnComponents.map(
column => new Column(column.componentInstance)
);
- columnComponents.forEach(column => {
- Object.keys(this.$options.props).forEach(
- prop => this.$watch(prop, () => this.mapColumns())
- );
- });
}, Well, I don't understand but it just works. One more thing. watch: {
data() {
+ // this.mapColumns(); // don't works
+ setTimeout(() => this.mapColumns(), 0);
+
if (this.usesLocalData) {
this.mapDataToRows();
}
},
}, (Confused Jackie Chan face) |
You're right about watching those props, and I also have no idea why they work now 😄 I'll look into this issue again later this week :) |
Hey, is there any progress of this issue? I had submit a PR #52 for this, it will be very appreciated if you could spend some time for it. Great thanks. |
Hi! Was on holiday so a bit later on this one :) Looks good to me, merged and tagged a fresh |
When binding data on table-column, table would not be updated as data is updating.
Here is a simple demo.
https://jsfiddle.net/p0fe9s06/5/
I have done some research and found Evan You(@yyx990803) has mention in vuejs/vue#4332
So I try to add watch in the TableColumn
and this in the TableComponent
Although it works fine, but it's not seems like an elegant approch.
Does anybody have a clue about this?
The text was updated successfully, but these errors were encountered: