Results 1 to 5 of 5

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

  1. #1
    Sencha User
    Join Date
    Oct 2012
    Posts
    6
    Answers
    1
    Vote Rating
    0
      0  

    Default 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 User mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    40,060
    Answers
    3976
    Vote Rating
    1389
      0  

    Default

    So it looks like all you want to do is add '<div style="color: white;">{contents}</div>' correct?
    Mitchell Simoens @LikelyMitch
    Modus Create, Senior Frontend Engineer
    ________________
    Need any sort of Ext JS help? Modus Create is here to help!

    Check out my GitHub:
    https://github.com/mitchellsimoens

  4. #3
    Sencha User
    Join Date
    Oct 2012
    Posts
    6
    Answers
    1
    Vote Rating
    0
      0  

    Default 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 User mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    40,060
    Answers
    3976
    Vote Rating
    1389
      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 @LikelyMitch
    Modus Create, Senior Frontend Engineer
    ________________
    Need any sort of Ext JS help? Modus Create is here to help!

    Check out my GitHub:
    https://github.com/mitchellsimoens

  6. #5
    Sencha User
    Join Date
    Oct 2012
    Posts
    6
    Answers
    1
    Vote Rating
    0
      0  

    Default Thanks!

    Works perfectly! Thanks very much.

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
  •