Results 1 to 2 of 2

Thread: list within a list in itemtpl

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Sencha User
    Join Date
    Jan 2012
    Posts
    1
    Vote Rating
    0
      0  

    Default 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 - Sr Software Engineer mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    39,411
    Answers
    3898
    Vote Rating
    1290
      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 @LikelyMitch
    Sencha Inc, Senior Software Engineer
    ________________
    Learn BBCode and use it!

    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.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •