leizz
17 Nov 2010, 2:13 PM
Hi,
I'm pretty new to Ext JS and would like some help on this:
In a long form I have multiple combo boxes. I'd like to load all of their options in one JSON call to save some server round trips. Here is a sample of my JSON:
{
"dropdownChoices": {
"wireTypes": [
{"desc": "Domestic Commercial", "code": "DOM_COMM" },
{"desc": "International Commercial", "code": "INTL_COMM" },
{"desc": "Domestic Bank to Bank", "code": "DOM_BK2BK" },
{"desc": "International Bank to Bank", "code": "INTL_BK2BK" }
],
"customerTypes": [],
"transferInouts": [],
"transferCurrencies": []
}
}And here is my store setup:
DropdownChoicesStore = Ext.extend(Ext.data.JsonStore, {
constructor: function(cfg) {
cfg = cfg || {};
DropdownChoicesStore.superclass.constructor.call(this, Ext.apply({
storeId: 'dropdownChoicesStore',
url: 'data/dropdownChoices.json',
root: 'dropdownChoices',
autoSave: false,
fields: [
{
name: 'wireTypesDesc',
mapping: 'wireTypes.desc'
},
{
name: 'wireTypesCode',
mapping: 'wireTypes.code'
}
]
}, cfg));
}
});When I try loading the form in browser, I see from FireBug that the JSON file is correctly sent back from the server, but the combo box doesn't display the options correctly.
If I change the store config as below then the dropdown works fine:
root: 'dropdownChoices.wireTypes',
fields: [
{
name: 'wireTypesDesc',
mapping: 'desc'
},
{
name: 'wireTypesCode',
mapping: 'code'
}
]Is there a way to organize the JSON data structure so that the Ext store can accept a 'parent-store' while allowing field mappings point into the nested "sub-stores"?
Could anyone help?
Thanks,
leizz
I'm pretty new to Ext JS and would like some help on this:
In a long form I have multiple combo boxes. I'd like to load all of their options in one JSON call to save some server round trips. Here is a sample of my JSON:
{
"dropdownChoices": {
"wireTypes": [
{"desc": "Domestic Commercial", "code": "DOM_COMM" },
{"desc": "International Commercial", "code": "INTL_COMM" },
{"desc": "Domestic Bank to Bank", "code": "DOM_BK2BK" },
{"desc": "International Bank to Bank", "code": "INTL_BK2BK" }
],
"customerTypes": [],
"transferInouts": [],
"transferCurrencies": []
}
}And here is my store setup:
DropdownChoicesStore = Ext.extend(Ext.data.JsonStore, {
constructor: function(cfg) {
cfg = cfg || {};
DropdownChoicesStore.superclass.constructor.call(this, Ext.apply({
storeId: 'dropdownChoicesStore',
url: 'data/dropdownChoices.json',
root: 'dropdownChoices',
autoSave: false,
fields: [
{
name: 'wireTypesDesc',
mapping: 'wireTypes.desc'
},
{
name: 'wireTypesCode',
mapping: 'wireTypes.code'
}
]
}, cfg));
}
});When I try loading the form in browser, I see from FireBug that the JSON file is correctly sent back from the server, but the combo box doesn't display the options correctly.
If I change the store config as below then the dropdown works fine:
root: 'dropdownChoices.wireTypes',
fields: [
{
name: 'wireTypesDesc',
mapping: 'desc'
},
{
name: 'wireTypesCode',
mapping: 'code'
}
]Is there a way to organize the JSON data structure so that the Ext store can accept a 'parent-store' while allowing field mappings point into the nested "sub-stores"?
Could anyone help?
Thanks,
leizz