1. #1
    Ext JS Premium Member
    Join Date
    Mar 2009
    Location
    San Mateo, CA
    Posts
    32
    Vote Rating
    4
    bergstyle is on a distinguished road

      2  

    Default Model Field Value Change Event

    Model Field Value Change Event


    Wondering how others are handling situations where you'd like to know if the value of a Model's field changes?

    One solution is to override the Model's afterEdit method.
    PHP Code:
        afterEdit: function() {
            var 
    me this;
            
    Ext.Object.each(me.modified, function(keyoldValueself) {
                if(
    oldValue) {    
                    
    me.fireEvent(key+'modified'meme.get(key), oldValue);
                }
            });
            
    this.callParent(arguments);
        } 
    Here's another solution that leverages the store's 'update' event which is fired in the model's afterEdit method.
    PHP Code:
        listeners: {
            
    update: function(storerecordmodelOperation) {
                if(
    modelOperation === 'edit') {
                    
    Ext.Object.each(record.modified, function(keyoldValueself) {
                        if(
    oldValue) {    
                            
    record.fireEvent(key+'modified'meme.get(key), oldValue);
                        }
                    });
                }
            }, 
    With either approach I can setup listeners for fieldnamemodified events on the model. Its not bad but it seems Ext.data.Field should have an event like this.
    Last edited by bergstyle; 29 Jun 2011 at 9:24 PM. Reason: added if(oldValue) to prevent firing extraneous events

  2. #2
    Sencha User
    Join Date
    Aug 2012
    Posts
    37
    Vote Rating
    3
    andreas-spindler is on a distinguished road

      0  

    Default


    I'm also in the need of knowing if a value on a model has changed. It's a pitty, that there is no 'propertychanged" event for the model. I give your idea with the overridden afterEdit method a try.

    Thanks for the idea!

  3. #3
    Sencha User
    Join Date
    Aug 2012
    Posts
    37
    Vote Rating
    3
    andreas-spindler is on a distinguished road

      0  

    Default


    Ok, this works quite nice, but only for "direct" fields of the model.
    Anyone has an idea how to override a model (not inside a store!) to get notified if a new hasOne Association is set?

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