-
12 Apr 2012 8:45 AM #1
Unanswered: Data in Subgroups - Uncaught TypeError: Cannot read property 'length' of undefined
Unanswered: Data in Subgroups - Uncaught TypeError: Cannot read property 'length' of undefined
Hello guys,
I have a problem with my store and my model i think.
I want to show a list but my data store is in sub-groups, so I have to use "associations" but I get the error message : "Uncaught TypeError: Cannot read property 'length' of undefined"
This is my code:
Data (Example):
Store:Code:{"root":[{"TipoPosAnt":"Z010","Reembolsable":null,"DsctoMontTotal":0,"Repartos":[{"TipoReparto":"Z1","Pos":"0001","PosCorto":"1","FechaEntrega":"\/Date(1331096400000)\/","CantPed":40.000,"CantConf":0.000,"CodUMedida":null}],"ConversionUMedida":"1 CJ"}]}
Model:Code:var detalleCabStore = new Ext.data.Store ({ autoLoad: true, model: 'detalleCabModel' });
List:Code:Ext.regModel('detalleCabModel', { fields: [ {name: 'Posicion', type: 'string'}, {name: 'CodMaterialCorto', type: 'string'}, {name: 'DescMaterial', type: 'string'}, {name: 'Cantidad', type: 'string'}, {name: 'CodUMedida', type: 'string'}, {name: 'Rendimiento', type: 'string'}, {name: 'CodCentro', type: 'string'}, {name: 'CodAlmacen', type: 'string'}, {name: 'CodLote', type: 'string'}, {name: 'PrecioSinIGV', type: 'string'}, {name: 'DsctoMontTotal', type: 'string'}, {name: 'Reparto', type: 'string'}, {name: 'FechaEntrega', type: 'string'}, {name: 'SubTotal', type: 'string'} ], proxy: { id: 'status', type: 'rest', url: 'data/detalleCabecera.txt', reader: { type: 'json', root: 'root' } }, hasMany: { model: 'repartoModel', name: 'Repartos' } }); Ext.regModel('repartoModel', { fields: [ {name: 'FechaEntrega', type: 'string'}, {name: 'TipoReparto', type: 'string'} ], proxy: { id: 'status', type: 'rest', url: 'data/detalleCabecera.txt', reader: { type: 'json', root: 'Repartos' } }, belongsTo: { model: 'detalleCabModel', name: 'root' } });
I hope you can help me.Code:this.lDoc = new Ext.List({ id: 'listaDoc', grouped: false, itemTpl: listDoc, loadingText: false, store: detalleCabStore, prepareData: function(data, index, record) { return data; } });
Thanks for everything!
-
12 Apr 2012 11:39 AM #2Sencha - Senior Forum Manager
- Join Date
- Mar 2007
- Location
- St. Louis, MO
- Posts
- 34,121
- Vote Rating
- 453
- Answers
- 3160
What is firing the error? Is it from the template or the model?
Mitchell Simoens @SenchaMitch
Sencha Inc, Senior Forum Manager
________________
http://www.JSONPLint.com - Source to lint your JSONP!
Check out my GitHub, lots of nice things for Ext JS 4 and Sencha Touch 2
https://github.com/mitchellsimoens
Think my support is good? Get more personalized support via a support subscription. https://www.sencha.com/store/
Need more help with your app? Hire Sencha Services services@sencha.com
Want to learn Sencha Touch 2? Check out Sencha Touch in Action that is almost in print!
When posting code, please use BBCode's CODE tags.
-
12 Apr 2012 11:46 AM #3
I think is the model, because my template is ok, I used before with data that aren't inside a group of my text store file and I don't had any problem.
Here is the code:
Tpl:
Code:var listDoc = '<div class="materialItem">'+ '<div class="doc-img"><img src="resources/images/cabdet_icon.png" width="40" height="40"></div>'+ '<div class="list-cabi">'+ '<span class="list-izq">{Posicion} {CodMaterialCorto} Cant: {Cantidad} - {CodUMedida} Rend: {Rendimiento}</span>'+ '<br />'+ '{DescMaterial}'+ '<br />'+ '{CodCentro}::Distribucion / {CodAlmacen} (Almacen) / {CodLote}'+ '</div>'+ '<div class="list-cabd">'+ '<span>Precio Unit: {PrecioSinIGV}'+ '<br />'+ 'Total Dcto: {DsctoMontTotal}'+ '<br />'+ '{FechaEntrega} Subtotal: {SubTotal}</span>'+ '</div>'+ '</div>';


Reply With Quote