繁体   English   中英

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

[英]Ag-grid - Events and Methods (Vuejs)

我无法使用“保存”方法保存对表数据的更改

我正在使用“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-value-changed 的事件回调

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

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

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

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM