首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Ag-网格-事件和方法(Vuejs)

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

Stack Overflow用户
提问于 2019-11-12 17:40:58
回答 1查看 764关注 0票数 0

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

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

代码语言:javascript
复制
<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)
},

错误消息:在这里输入图像描述

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2019-11-13 15:37:49

若要达到预期结果,请使用@cell-value-changed的事件回调。

  1. 将事件更改为@单元格值-更改=“保存”
  2. 使用事件回调获取单元格的旧值和新值
代码语言:javascript
复制
 `save(event) {                     console.log('onCellValueChanged: ' + event.oldValue + ' to ' + event.newValue);                 }` 
  1. 从事件回调中获取必需的id值,并将其用于POST调用
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/58823944

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档