Hybrid View
-
27 Nov 2012 2:41 PM #1
Answered: Dynamically change list item's icon
Answered: Dynamically change list item's icon
So I have a List inside a view, it use itemTpl to create customized item template.
But i have a problem now. When I click one of the item, i want to change the picture inside that tpl which isCode:this.list = Ext.create('Ext.List', { xtype: 'gameList', title: 'Game List', id: 'gameList', ui: 'round', flex: 1, width: 300, store: 'Games', cls: 'gameList', itemTpl: Ext.create('Ext.XTemplate', '<div class="game">', '<img class="gameuserpic" src="{userPic}" />', '<img class="gamemoveimg" src="resources/images/{action}.png"/>', '<p class="info">{userName}</p>', '<p class="move">{move}</p>', '</div>'), //end itemTPl });the {action} is from the store. so i just directly change it by usingCode:'<img class="gamemoveimg" src="resources/images/{action}.png"/>',but I have to call refresh function to get the list updated!! now the problem is , when you call Ext.getCmp('gameList').refresh() , the list suddenly goes to the top, it lost the original position!!Code:clickGame: function(view, index, item, e) {e.getData().action = 'waiting';}
How can I refresh the list without changing the current position ?
-
Best Answer Posted by bricemason
The itemtap event on Ext.dataview.List provides the record as part of its argument list. You can handle it like this:
and the item will update in place.Code:listeners: { itemtap: function(dataview, index, targetEl, record) { record.set('action', 'waiting'); } }
Brice
-
27 Nov 2012 6:47 PM #2
The itemtap event on Ext.dataview.List provides the record as part of its argument list. You can handle it like this:
and the item will update in place.Code:listeners: { itemtap: function(dataview, index, targetEl, record) { record.set('action', 'waiting'); } }
BriceBrice Mason
Front End Developer
Modus Create
@bricemason
bricemason.com
Sencha Touch Screencasts
Vimeo - Sencha Touch Channel
Github Projects:
Sencha Cordova Builder enables the automatic creation, building, and running of PhoneGap (Cordova) projects with Sencha Touch.
Am I Sencha Touch Ready? checks your system to determine what you need to do to start Sencha Touch development. If you're having trouble getting up and running, try this out.
Sencha Tools Bridge allows Sencha SDK Tools to co-exist with Sencha Cmd on the same system.


Reply With Quote