1. #1
    Sencha User
    Join Date
    Jan 2012
    Posts
    1
    Vote Rating
    0
    abintoms is on a distinguished road

      0  

    Default Unanswered: list within a list in itemtpl

    Unanswered: list within a list in itemtpl


    Hi all,
    I have a list of employees. Each employee can be associated with more than 1 departments.
    I am able to show the list of employees using itemTpl. How do I show the department list?
    I tried adding tpl for loop:
    <tpl for="departments">{departments.deptName}</tpl> However that doesn't work.

    My list is a list of
    Code:
                         {                    xtype: 'list',
                        id: 'myList',
                        itemId:"myListId",
                        itemTpl: "<div ><table>" +
                            "<tr><td>Employee Name  </td><td>{empName}</td><td>Designation  </td><td>{designation}</td></tr>" +                                         
                            "<tr><td><tpl for="departments">{departments.deptName}</tpl>  </td></tr>" +
                            "</table></div>",
                        flex: 1,
                        store:{
                            id: 'myStore',
                            model:'myModel',
                            data: ''
                        },
                        width: '100%'
                    }
    Thanks

  2. #2
    Sencha - Senior Forum Manager mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    37,065
    Answers
    3499
    Vote Rating
    852
    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


    Code:
    <tpl for="departments">{departments.deptName}</tpl>
    The <tpl for="departments"> part is telling the XTemplate that it can loop through an array of objects. So therefore you only need to do {deptName} as you are now with in an object within that array.
    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.

Thread Participants: 1

Tags for this Thread