Ag网格-事件和方法(Vuejs)



我不能使用"save"方法保存对我的表数据的更改

我正在使用"cellValueChanged"方法来编辑和保存表格单元格。

<ag-grid-vue :cellValueChanged="save"></ag-grid-vue>
methods: {
save() {
const method = this.instituicao.id ? 'put' : 'post'
const id = this.instituicao.id ? `/${this.instituicao.id}` : ''
axios[method](`${baseApiUrl}/instituicao${id}`, this.instituicao)
.then(() => {
this.$toasted.global.defaultSuccess()
this.reset()
})
.catch(showError)
},

错误消息:在此处输入图像描述

为了达到预期的结果,使用@cell值更改的事件回调

  1. 将事件更改为@cell value-changed="save">
  2. 使用事件回调获取单元格的旧值和新值

save(event) { console.log('onCellValueChanged: ' + event.oldValue + ' to ' + event.newValue); }

  1. 从该事件回调中获取所需的id值,并将其用于POST调用

最新更新