Skip to content

Commit 6fbdd21

Browse files
Ray FossSamuell1
authored andcommitted
fix(MdTable): nextTick selection data (#1874)
* comp(mdTable): nextTick selection data The current implementation couldn't handle selection data and table data at the same time #1866 * comp(MdTable): also handle case #2 AOT providing selection data Ahead of Time, aka, ahead of table data, will also break MdTable. This handles both cases. * comp(MdTable): remove redundant nextTick * comp(MdTable): merge glitch fix
1 parent 87f95fb commit 6fbdd21

File tree

1 file changed

+11
-8
lines changed

1 file changed

+11
-8
lines changed

src/components/MdTable/MdTable.vue

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -257,6 +257,9 @@
257257
},
258258
mdSelectedValue () {
259259
this.syncSelectedValue()
260+
},
261+
value () {
262+
this.syncSelectedValue()
260263
}
261264
},
262265
methods: {
@@ -333,11 +336,13 @@
333336
this.$emit('md-selected', val)
334337
},
335338
syncSelectedValue () {
336-
if (this.MdTable.selectingMode === 'single') {
337-
this.MdTable.singleSelection = this.mdSelectedValue
338-
} else if (this.MdTable.selectingMode === 'multiple') {
339-
this.MdTable.selectedItems = this.mdSelectedValue || []
340-
}
339+
this.$nextTick().then(() => { // render the table first
340+
if (this.MdTable.selectingMode === 'single') {
341+
this.MdTable.singleSelection = this.mdSelectedValue
342+
} else if (this.MdTable.selectingMode === 'multiple') {
343+
this.MdTable.selectedItems = this.mdSelectedValue || []
344+
}
345+
})
341346
},
342347
setWidth () {
343348
if (this.mdFixedHeader) {
@@ -350,9 +355,7 @@
350355
this.sortTable()
351356
}
352357
353-
this.$nextTick().then(() => {
354-
this.syncSelectedValue()
355-
})
358+
this.syncSelectedValue()
356359
},
357360
mounted () {
358361
this.setContentEl()

0 commit comments

Comments
 (0)