1. #1
    Sencha User
    Join Date
    Oct 2012
    Posts
    6
    Answers
    1
    Vote Rating
    0
    bongo_bongo is on a distinguished road

      0  

    Default Answered: custom itemTpl for a "tapped" row in list

    Answered: custom itemTpl for a "tapped" row in list


    Hi

    Is there a way to setItemTpl dynamically for only the tapped row of a list?

    Currently i can do that but it applies to all rows...

    Currently I have the following:
    Code:
     {
                xtype      : 'list',
                id: 'airportGuideShopsList',
                itemId: 'airportGuideShopsList',
                scrollable : {
                    direction     : 'vertical',
                    directionLock : true
                },
                itemCls : 'airport-guide-shop',
                itemTpl    : '<div class="off-white-text" style="font-size: 14px;">{name}</div>',
                store      : 'ShopsStore',
                listeners: {
                    itemtap : function(list, idx, el){
    
    
                        if(el.getHeight()<300){
                            el.setHeight(300);
                            list.setItemTpl('<div class="off-white-text" style="font-size: 14px;">{name}</div><div style="color: white;">{contents}</div>')
                        
                           
                        }else{
                            el.setHeight(50);
                            list.setItemTpl('<div class="off-white-text" style="font-size: 14px;">{name}</div>');
                        }
                        list.refresh();
                    }
                }
            }
    Thanks

  2. Works perfectly! Thanks very much.

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


    So it looks like all you want to do is add '<div style="color: white;">{contents}</div>' correct?
    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.

  4. #3
    Sencha User
    Join Date
    Oct 2012
    Posts
    6
    Answers
    1
    Vote Rating
    0
    bongo_bongo is on a distinguished road

      0  

    Default Itemtpl

    Itemtpl


    Yes I am trying to display {contents}
    On the tap of the row item in list but only for the tapped row.

    At the moment it shows up in all rows.

    I am using your accordion layout and have a list inside an accordion container.
    Thanks a lot for your support:

  5. #4
    Sencha - Senior Forum Manager mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    37,347
    Answers
    3542
    Vote Rating
    846
    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


    If you want the div to show when that row is selected then you can use CSS and always have the 2nd div there but hidden unless the row is selected.

    If you want to toggle based on tapping them you can set a field on the model and when itemtap fires you can then toggle that field then in your itemTpl you can do:

    Code:
    '<div class="off-white-text" style="font-size: 14px;">{name}</div><tpl if="someField"><div style="color: white;">{contents}</div></tpl>'
    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.

  6. #5
    Sencha User
    Join Date
    Oct 2012
    Posts
    6
    Answers
    1
    Vote Rating
    0
    bongo_bongo is on a distinguished road

      0  

    Default Thanks!

    Thanks!


    Works perfectly! Thanks very much.

Thread Participants: 1

Tags for this Thread