user1893874
user1893874

Reputation: 843

Bind text from value in RowEditing

I am implementing a RowEditing functionality

Here is one of the grid column

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' }
    ]
  })
}

Stored procedure returns only city Id, that is 1 or 2. Now because I used " dataIndex: 'City_id' " at the header - only 1 or 2 is binding to the grid.

My question here is, in this I want to bind text not value to the display. How can I do this? Please suggest me.

Upvotes: 0

Views: 164

Answers (2)

Robert Watkins
Robert Watkins

Reputation: 2206

@Alexander's answer is the right way to go for updating the displayed value in the column.

To fix the issue with the column header, use the text property, not the header property, in the first line of your code sample.

Column config:

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

Upvotes: 0

Alexander
Alexander

Reputation: 20224

Usually you would use a renderer on the column to display the text instead of the value.

Something along the lines of:

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

Upvotes: 1

Related Questions