1. #1
    Touch Premium Member
    Join Date
    May 2011
    Posts
    2
    Vote Rating
    0
    luik is on a distinguished road

      0  

    Default XTemplate with nested models

    XTemplate with nested models


    I have a following structure: Shipments (Shipment contains packages, packages contains items).
    My models, store an data are in the attachment. (I think they are ok)

    When I try to create a template :

    Code:
    store: 'Shipments',
    itemSelector: '',
    tpl: new Ext.XTemplate(
        '<div>',
            '<tpl for=".">',
                   '<div><h2>Shipment {id}</h2></div>',
                     '<tpl for="packages">',
                         '<div><h3>Package {id}</h3></div>',
                           '<tpl for="items">',
                               '<div>Item {id}</div>',
                           '</tpl>',
                     '</tpl>',
            '</tpl>',
        '</div>'
    )
    as output I get only:

    Shipment 1
    Shipment 2

    Does anyone know why this doesn't work?

    Thanks.
    Attached Files

  2. #2
    Sencha Premium Member
    Join Date
    May 2010
    Location
    Guatemala, Central America
    Posts
    1,305
    Vote Rating
    106
    ssamayoa is just really nice ssamayoa is just really nice ssamayoa is just really nice ssamayoa is just really nice

      0  

    Default


    I have a similar need (nested model) and struggled for a while but at last I found a post stating that templates only accepts arrays and doesn't suppoets nested stores.

    Is your "structure" a plain JS object with array properties or model instance with hasMany relationship?

    If former and doesn't work means that nested arrays arent supported.

    Otherwise (instance with hasMany relationship) you have to look for altermative (I did) because templates doesn't support them.

    Regards.
    UI: Sencha Architect 3.x / ExtJS 4 & 5
    Server side: JEE / EJB 3.x / CDI / JPA 2.x/ JAX-RS / JasperReports
    Application Server: Glassfish / WildFly
    Databases: Oracle / DB2 / MySQL / Firebird

    If you like my answer please vote!

  3. #3
    Sencha Premium Member
    Join Date
    Nov 2012
    Location
    Bangalore
    Posts
    79
    Vote Rating
    1
    rupamkhaitan is on a distinguished road

      0  

    Default


    Can you please elaborate ?

Thread Participants: 2

Tags for this Thread