1. #1
    Sencha User
    Join Date
    Apr 2013
    Posts
    34
    Answers
    2
    Vote Rating
    0
    jjaskols is on a distinguished road

      0  

    Default Answered: Problem updating content in DataItem/ListItem

    Answered: Problem updating content in DataItem/ListItem


    Hello,

    I ran into another issue that kept me wondering all day now.

    I want to change an image in a ListItem, depending on a data field in the list record. More precisely: "status", which can either be true or false, dictates if an image shows "On"- or "Off"-Symbols.

    I am updating the underlying datastore through this:

    Code:
    var img = Ext.ComponentQuery.query('x-groupdataitem')[index];
    var store = Ext.getStore('groupstore');
    var i = store.findExact('device_name', img._name._html);
    store.getAt(i).set('status', Boolean(JSON.parse(response.responseText)['newState'));
    This reliably updates the "status" field in the corresponding record. However, I continue to fail at the task of finding a way, so that the image changes according to the "status" field changes.

    I am using the updateRecord(record); function in the ListItem in the following way:

    Code:
    updateRecord: function(record) {
    if(record.data.status) {
      this.getStatusButton().setSrc('resources/icons/onbutton.jpg');
    } else {
      this.getStatusButton().setSrc('resources/icons/offbutton.jpg');
    }
    this.updateStatusButton(this.getStatusButton());
    this.callParent(arguments);
    }
    I get no errors, no mispelled syntax, and every field actually contains what its supposed to. Even the imgSrc field contains the RIGHT url!!!

    I would be grateful for any tips,
    Janik

  2. Try it like this and see if it works:

    Code:
    updateRecord: function(record) {
    this.callParent(arguments);
    if(record.get('status')) { //You Should always use the record.get() syntax
      this.getStatusButton().setSrc('resources/icons/onbutton.jpg');
    } else {
      this.getStatusButton().setSrc('resources/icons/offbutton.jpg');
    }
    
    this.updateStatusButton(this.getStatusButton()); //I don't think you even need this line.
    
    }

  3. #2
    Sencha User
    Join Date
    Apr 2012
    Posts
    164
    Answers
    13
    Vote Rating
    9
    in4p will become famous soon enough

      0  

    Default


    Try it like this and see if it works:

    Code:
    updateRecord: function(record) {
    this.callParent(arguments);
    if(record.get('status')) { //You Should always use the record.get() syntax
      this.getStatusButton().setSrc('resources/icons/onbutton.jpg');
    } else {
      this.getStatusButton().setSrc('resources/icons/offbutton.jpg');
    }
    
    this.updateStatusButton(this.getStatusButton()); //I don't think you even need this line.
    
    }

  4. #3
    Sencha User
    Join Date
    Apr 2013
    Posts
    34
    Answers
    2
    Vote Rating
    0
    jjaskols is on a distinguished road

      0  

    Default


    Yes, works like a charm. Thanks a lot!!!

    Thus: this.callParent must always be first!!!

    Oh and heads up, this.callParent() requires an array if its in the constructor. Is this always the case!?!

Thread Participants: 1

Tags for this Thread

Turkiyenin en sevilen filmlerinin yer aldigi xnxx internet sitemiz olan ve porn sex tarzi bir site olan mobil porno izle sitemiz gercekten dillere destan bir durumda herkesin sevdigi bir site olarak tarihe gececege benziyor. Sitenin en belirgin ozelliklerinden birisi de Turkiyede gercekten kaliteli ve muntazam, duzenli porno izle siteleri olmamasidir. Bu yuzden iste. Ayrica en net goruntu kalitesine sahip adresinde yayinlanmaktadir. Mesela diğer sitelerimizden bahsedecek olursak, en iyi hd porno video arşivine sahip bir siteyiz. "The Best anal porn videos and slut anus, big asses movies set..." hd porno faketaxi