hi I'm trying to use convert config of field
but get this error
TypeError: 'undefined' is not an object (evaluating 'record.retailer.name')
this is my model
Code:
function retailerDetail(v, record){
return record.retailer.name + ', ' + record.retailer.retailerID+','+record.retailer.URL;
}
function locationDetail(v,record)
{
return record.location.line1+','+record.location.line2+','+record.location.city+','+record.location.postcode;
}
function vatDetail(v,record)
{
return record.vat.rate+','+record.vat.net+','+record.vat.vat+','+record.vat.gross;
}
Ext.regModel('receipts_model', {
fields:[
{name:'timestamp',type:'auto'},
{name:'receiptID',type:'auto'},
{name:'Identifier',type:'auto'},
{name:'retailer',convert:retailerDetail},
{name:'name',mapping:'retailer.name'},
{name:'retailerID',mapping:'retailer.retailerID'},
{name:'URL',mapping:'retailer.URL'},
{name:'transactionID',type:'auto'},
{name:'postcode',type:'auto'},
{name:'location',convert:locationDetail},
{name:'line1',mapping:'location.line1'},
{name:'line2',mappimg:'location.line2'},
{name:'city',mapping:'location.city'},
{name:'locationPostcode',mapping:'location.postcode'},
{name:'total' ,type:'auto'},
{name:'vat',convert:vatDetail},
{name:'rate',mapping:'vat.rate'},
{name:'net',mapping:'vat.net'},
{name:'vatAmount',mapping:'vat.vat'},
{name:'gross',mapping:'vat.gross'},
],
associations:[
{type: 'hasMany', model: 'testItemModel'},
{type:'hasMany',model:'testOfferModel'}
],
});
this is my store
Code:
LoginForm.receipts_store =new Ext.data.Store({
model : 'receipts_model',
sorters: 'purchaseDate',
data: [
{timestamp: '15:32 15 October 2011', receiptID: '123451', Identifier:'9876543210',retailer:{name:'Marks and Spencers',retailerID:'770000000001',URL:'images/Morrisons Logo.jpg'},transactionID:'5487854241',postcode:"EC3V3NP",total:'52.78',vat:{rate:'20',net:'43.98',vat:'8.8',gross:'52.78'}},
] });
the data for which i'm trying to create the model
Code:
[ { "timestamp":"15:32 15 October 2011", "receiptID":123451, "identifier":9876543210, "retailer":{ "name":"Marks and Spencers", "retailerID":"770000000001", "retailer_image_url":"http://paprless.com/770000000001/public.png" }, "transactionID":5487854241, "postcode":"EC3V3NP", "location":{ "line1":"25 West 2nd Street", "line2":"", "city":"London", "postcode":"EC3V3NP" }, "item":[ {"name":"SCIENCE PUTTY", "qty":1, "amount":5}, {"name":"WNC STRAW MLW LPOP", "qty":1, "amount":0.79}, {"name":"RIDLEYS CLASSIC JOKE", "qty":1, "amount":7}, {"name":"BRUT CHAMPAGNE MAG", "qty":1, "amount":39.99} ], "total":52.78, "vat":{ "rate":20, "net":43.98, "vat":8.8, "gross":52.78}, "returns":[ ], "offer":{ "offerID":555555, "condition":"Buy One", "reward":"Get One Free", "creator":"Travis Perkins", "status":"live", "image_url":"http://paprless.com/offers/555555/smart.png" } } ]
i'm also not sure whether i'm using the convert config properly
also i want to know how to map the values returned by the function
please guide