Threaded View

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


    Default 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() {
    me this;
    Ext.Object.each(me.modified, function(keyoldValueself) {
    oldValue) {    
    me.fireEvent(key+'modified'meme.get(key), oldValue);
    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) {
    modelOperation === 'edit') {
    Ext.Object.each(record.modified, function(keyoldValueself) {
    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 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

Thread Participants: 1

Tags for this Thread