Update edit-cell.md (#605)

pull/621/head
HelloMoli 2019-03-19 10:36:46 +08:00 committed by tangjinzhou
parent 82081f1d82
commit 9f9ab21ff3
1 changed files with 2 additions and 4 deletions

View File

@ -14,7 +14,7 @@ Table with editable cells.
<a-button class="editable-add-btn" @click="handleAdd">Add</a-button>
<a-table bordered :dataSource="dataSource" :columns="columns">
<template slot="name" slot-scope="text, record">
<editable-cell :text="text" @change="onCellChange(record.key, 'name')"/>
<editable-cell :text="text" @change="onCellChange(record.key, 'name', $event)"/>
</template>
<template slot="operation" slot-scope="text, record">
<a-popconfirm
@ -69,15 +69,13 @@ export default {
}
},
methods: {
onCellChange (key, dataIndex) {
return (value) => {
onCellChange (key, dataIndex, value) {
const dataSource = [...this.dataSource]
const target = dataSource.find(item => item.key === key)
if (target) {
target[dataIndex] = value
this.dataSource = dataSource
}
}
},
onDelete (key) {
const dataSource = [...this.dataSource]