Ag-grid - 事件和方法 (Vuejs)

Ag-grid - Events and Methods (Vuejs)

我无法使用 "save" 方法保存对 table 数据的更改

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

<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)
},

错误信息: enter image description here

为达到预期效果,使用@cell-value-changed

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

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

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