1. #1
    Sencha User
    Join Date
    Sep 2012
    Posts
    11
    Vote Rating
    0
    reco123 is on a distinguished road

      0  

    Default 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.
    Code:
        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
        });
    But i have a problem now. When I click one of the item, i want to change the picture inside that tpl which is
    Code:
    '<img class="gamemoveimg" src="resources/images/{action}.png"/>',
    the {action} is from the store. so i just directly change it by using
    Code:
    clickGame: function(view, index, item, e) {e.getData().action = 'waiting';}
    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!!
    How can I refresh the list without changing the current position ?

  2. The itemtap event on Ext.dataview.List provides the record as part of its argument list. You can handle it like this:

    Code:
    listeners: {
       itemtap: function(dataview, index, targetEl, record) {
          record.set('action', 'waiting');
       }
    }
    and the item will update in place.

    Brice

  3. #2
    Sencha Premium Member bricemason's Avatar
    Join Date
    Jan 2008
    Location
    Upstate NY
    Posts
    280
    Answers
    49
    Vote Rating
    42
    bricemason has a spectacular aura about bricemason has a spectacular aura about bricemason has a spectacular aura about

      0  

    Default


    The itemtap event on Ext.dataview.List provides the record as part of its argument list. You can handle it like this:

    Code:
    listeners: {
       itemtap: function(dataview, index, targetEl, record) {
          record.set('action', 'waiting');
       }
    }
    and the item will update in place.

    Brice
    Brice 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.

Thread Participants: 1

film izle

hd film izle

film sitesi

takipci kazanma sitesi

takipci kazanma sitesi

güzel olan herşey

takipci alma sitesi

komik eğlenceli videolar