-
23 Oct 2012 7:39 AM #1
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:
ThanksCode:{ 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(); } } }
-
Best Answer Posted by bongo_bongo
Works perfectly! Thanks very much.
-
24 Oct 2012 6:51 PM #2Sencha - Senior Forum Manager
- Join Date
- Mar 2007
- Location
- St. Louis, MO
- Posts
- 33,581
- Vote Rating
- 433
- Answers
- 3100
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
________________
http://www.JSONPLint.com - Source to lint your JSONP!
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 almost in print!
When posting code, please use BBCode's CODE tags.
-
25 Oct 2012 12:16 AM #3
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:
-
25 Oct 2012 4:06 AM #4Sencha - Senior Forum Manager
- Join Date
- Mar 2007
- Location
- St. Louis, MO
- Posts
- 33,581
- Vote Rating
- 433
- Answers
- 3100
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
________________
http://www.JSONPLint.com - Source to lint your JSONP!
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 almost in print!
When posting code, please use BBCode's CODE tags.
-
25 Oct 2012 11:30 AM #5
Thanks!
Thanks!
Works perfectly! Thanks very much.


Reply With Quote