In my Ext.data.Store
, I have language variables stored in JSON format like this:
{
"language":"en_GB",
"data":[
{"fieldName":"browserInfo","fieldValue":"Descriptive text"}
]
}
This is the store I've set up:
Ext.local.langStore = Ext.create('Ext.data.Store', {
autoLoad: true,
fields: [
{name: 'fieldName', type: 'string'},
{name: 'fieldValue', type: 'string'},
],
proxy: {
type: 'ajax',
url: 'en_GB.json',
reader: {
type: 'json',
root: 'data'
}
}
});
I'm attempting to retrieve the fieldValue
based on a specific fieldName
. How can I achieve this using Ext? I've tested with the following code snippet:
var getLabel = function(field_id) {
var store = Ext.local.langStore;
var index = store.findExact('fieldName',field_id);
if(index >= 0) {
return store.getAt(index).get('fieldValue');
} else {
return field_id;
}
}
Unfortunately, I haven't had much success with it as the index
always returns -1
.
Any assistance would be greatly appreciated,