Results 1 to 2 of 2

Thread: list within a list in itemtpl

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

    Default 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,556
    Answers
    3931
    Vote Rating
    1272
      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! Checkout the CODE tag!

    Check out my GitHub, lots of nice things for Ext JS and Sencha Touch
    https://github.com/mitchellsimoens

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
  •