Update edit-cell.md (#605)
parent
82081f1d82
commit
9f9ab21ff3
|
@ -14,7 +14,7 @@ Table with editable cells.
|
||||||
<a-button class="editable-add-btn" @click="handleAdd">Add</a-button>
|
<a-button class="editable-add-btn" @click="handleAdd">Add</a-button>
|
||||||
<a-table bordered :dataSource="dataSource" :columns="columns">
|
<a-table bordered :dataSource="dataSource" :columns="columns">
|
||||||
<template slot="name" slot-scope="text, record">
|
<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>
|
||||||
<template slot="operation" slot-scope="text, record">
|
<template slot="operation" slot-scope="text, record">
|
||||||
<a-popconfirm
|
<a-popconfirm
|
||||||
|
@ -69,15 +69,13 @@ export default {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
onCellChange (key, dataIndex) {
|
onCellChange (key, dataIndex, value) {
|
||||||
return (value) => {
|
|
||||||
const dataSource = [...this.dataSource]
|
const dataSource = [...this.dataSource]
|
||||||
const target = dataSource.find(item => item.key === key)
|
const target = dataSource.find(item => item.key === key)
|
||||||
if (target) {
|
if (target) {
|
||||||
target[dataIndex] = value
|
target[dataIndex] = value
|
||||||
this.dataSource = dataSource
|
this.dataSource = dataSource
|
||||||
}
|
}
|
||||||
}
|
|
||||||
},
|
},
|
||||||
onDelete (key) {
|
onDelete (key) {
|
||||||
const dataSource = [...this.dataSource]
|
const dataSource = [...this.dataSource]
|
||||||
|
|
Loading…
Reference in New Issue