1. #1
    Sencha User
    Join Date
    Mar 2012
    Posts
    104
    Vote Rating
    0
    Answers
    4
    izak18 is on a distinguished road

      0  

    Default 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):

    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"}]}
    Store:

    Code:
    var detalleCabStore = new Ext.data.Store ({
        autoLoad: true,
        model: 'detalleCabModel'
    });
    Model:

    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' }
    });
    List:

    Code:
    this.lDoc = new Ext.List({            id: 'listaDoc',
                grouped: false,
                itemTpl: listDoc,
                loadingText: false,
                store: detalleCabStore,
                prepareData: function(data, index, record) {
    			 return data;
    	   }
            });
    I hope you can help me.
    Thanks for everything!

  2. #2
    Sencha - Senior Forum Manager mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    37,525
    Vote Rating
    871
    Answers
    3564
    mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute

      0  

    Default


    What is firing the error? Is it from the template or the model?
    Mitchell Simoens @SenchaMitch
    Sencha Inc, Senior Forum Manager
    ________________
    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 in print!

    When posting code, please use BBCode's CODE tags.

  3. #3
    Sencha User
    Join Date
    Mar 2012
    Posts
    104
    Vote Rating
    0
    Answers
    4
    izak18 is on a distinguished road

      0  

    Default


    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}&nbsp;&nbsp;&nbsp;{CodMaterialCorto}&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Cant: {Cantidad}&nbsp;&nbsp;&nbsp;-&nbsp;&nbsp;&nbsp;{CodUMedida}&nbsp;&nbsp;&nbsp;Rend: {Rendimiento}</span>'+
    			'<br />'+
    			'{DescMaterial}'+
    			'<br />'+
    			'{CodCentro}::Distribucion&nbsp;&nbsp;/&nbsp;&nbsp;{CodAlmacen} (Almacen)&nbsp;&nbsp;/&nbsp;&nbsp;{CodLote}'+
            '</div>'+
            '<div class="list-cabd">'+
                '<span>Precio Unit: {PrecioSinIGV}'+
    			'<br />'+
    			'Total Dcto: {DsctoMontTotal}'+
    			'<br />'+
    			'{FechaEntrega}&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Subtotal: {SubTotal}</span>'+ 
            '</div>'+
        '</div>';

Thread Participants: 1

Tags for this Thread