从 RowEditing 中的值绑定文本

Bind text from value in RowEditing

我正在实现行编辑功能

这是其中一个网格列

header: 'City', dataIndex: 'City_id',
editor: {
  xtype: 'combobox',
  queryMode: 'local',
  displayField: 'text',
  valueField: 'value',
  store: Ext.create('Ext.data.Store', {
    fields: ['text', 'value'],
    data: [
        { text: 'Atlanta', value: '1' },
        { text: 'New York', value: '2' }
    ]
  })
}

存储过程 returns 只有城市 ID,即 1 或 2。现在因为我在 header 处使用了“dataIndex: 'City_id'” - 只有 1 或 2 绑定到网格。

我的问题是,在这里我想将文本而不是值绑定到显示。我怎样才能做到这一点?请建议我。

通常您会在列上使用渲染器来显示文本而不是值。

大致如下:

renderer:function(value) {
    return this.editor.store.findRecord("value",value).get("text");
}

@Alexander 的回答是更新列中显示值的正确方法。

要修复列 header 的问题,请在您的第一行使用 text 属性,而不是 header 属性代码示例。

列配置:

{ text: 'City', // NOT header: 'City' 
  dataIndex: 'City_id',
  editor: {
    ...
  }
}