PDA

View Full Version : [Solved] Testing JsonStore if obj field mapping exists



SlashEMc2k
5 Aug 2010, 11:03 AM
If a json object does not exist ie emails from the example below I get an error when I loadData.

Do I need to parse and restructure the response.responseText setting up the object emails with empty values or have I missed a property I can assign that says this is a dynamic field object if it is undefined create and set blank value?

Thanks/:)



{"items":[{"name":{"givenName":"Indy","formatted":"Indiana","familyName":"Jones"}]}



var storeConnectionsSetup = new Ext.data.JsonStore({
autoDestroy: true,
storeId: 'forumStore',
root: 'items',
idProperty: 'id',
fields: [{
name: 'givenName',
mapping: 'name.givenName'
}, {
name: 'displayName',
mapping: 'displayName'
}, {
name: 'familyName',
mapping: 'name.familyName'
}, {
name: 'UID',
mapping: 'id'
}, {
name: 'displayName',
mapping: 'displayName'
}, {
name: 'emails',
mapping: 'emails.value'
}, {
name: 'emailsType',
mapping: 'emails.type'
}]
});

storeConnectionsSetup.loadData(Ext.decode(response.responseText));


Found the solution. (http://www.sencha.com/forum/showthread.php?80061-JSON-JsonStore-mapping-field-doesn-t-work)

Attached property
convert: function(v){return v ? v.type : '';}