【问题标题】:Update cellEditorParams after table creation创建表后更新 cellEditorParams
【发布时间】:2020-09-13 10:19:06
【问题描述】:

我正在使用 Vue.js 使用 ag 网格来显示表格。我有一个这样的列定义:

        {
          headerName: "Status",
          field: "featureStatus",
          width: 110,
          editable: true,
          cellEditor: "agSelectCellEditor ",
          cellEditorParams: {
            values: []
          }
        },

this.allFeatureStatusNames 是一个返回字符串数组的计算变量:

 allFeatureStatusNames: function() {
      return this.allFeatureStatuses.map(status => status.name)
    }

我有一个关于 allFeatureStatuses 的观察者,我想在创建表后更新 cellEditorParams:

    allFeatureStatuses: function() {
      let colDef = this.columnDefs.find(col => col.headerName == "Status")

      if (colDef) {
        colDef.cellEditorParams = {
          values: this.allFeatureStatusNames
        }
      }

      this.gridColumnApi.refreshCells()
    },

我遇到的问题是单元格编辑器永远不会更新。它总是空的。表格创建后如何刷新或更新 cellEditorParams?

【问题讨论】:

    标签: ag-grid ag-grid-vue


    【解决方案1】:

    尽管使用您的方法,但问题可能是您的 colDef 对象没有得到更新,因为您正在尝试修改现有对象并创建新的 colDef 可能对您有用。

    像下面这样的东西对我有用 -

    cellEditorParams: this.getValues.bind(this);
    
    getValues: function() {
       let allowedVals = this.allFeatureStatusNames;
       return { values : allowedVals};
    }
    

    【讨论】:

      猜你喜欢
      • 2017-01-02
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-07-25
      • 1970-01-01
      • 2016-06-17
      相关资源
      最近更新 更多