View Full Version : How to make combobox work with nested field names?

9 Oct 2012, 2:12 PM
Hi all!

I have one problem with nested JSON data and combobox in ExtJS 4.1

When I set "displayField" to the field name like "name.name" I get empty list of combobox.

Ext.define("Model", {

extend: "Ext.data.Model",
fields: [
{name: "id", type: "int"},
{name: "name.name"},
{name: "phone", mapping: "name.phone"},
{name: "descr", type: "string", mapping:'description'}

// store with data that we will recieve from test echo ajax service
var Store = Ext.create("Ext.data.Store", {
model: "Model",
autoLoad: true,
proxy: {
type: 'ajax',
url: '/echo/json/',
actionMethods: {read: 'POST'}, // echo ajax service required
extraParams: {
json: Ext.JSON.encode({
root: [{id: 1, name: {name:"John", phone: "123"}, description:"Fapfapfap"},
{id: 2, name: {name:"Danny", phone: "234"}, description:"Boobooboo"},
{id: 3, name: {name:"Tom", phone: "345"}, description:"Tralala"},
{id: 4, name: {name:"Jane", phone: "456"}, description:"Ololo"},]
reader: {
type: 'json',
root: 'root'

When I set field 'name' mapping as below,

{name: "name", mapping: "name.name"}
and configure the combobox with "displayField" to "name" it works as intended.

But I have to use field name with original name 'name.name'.

Does anyone know what can best be done to solve this problem?

Maybe is it a bug?

This problem with examples is also posted on stackoverflow: http://stackoverflow.com/questions/12753340

Thanks in advance!

10 Oct 2012, 5:36 AM
I have found one solution. Not the best but it works for me.

I add new field with mapping configuration dynamically to store model when combo is init as component.

Details you can find here: http://stackoverflow.com/questions/12753340/how-to-change-the-code-so-that-combobox-shows-the-list-of-displayfield-values/12753855#12753855