delegans
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!
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!