You found a bug! We've classified it as TOUCH-4105 . We encourage you to continue the discussion and to find an acceptable workaround while we work on a permanent fix.
  1. #1
    Sencha User
    Join Date
    Oct 2012
    Posts
    3
    Vote Rating
    0
    rjrempe is on a distinguished road

      0  

    Default Suggested change - panel.js setRecord(record) cause event fire before record is set

    Suggested change - panel.js setRecord(record) cause event fire before record is set


    REQUIRED INFORMATION

    Ext version tested:
    • Sencha Touch 2.1

    Browser versions tested against:[LIST][*]CHROME 11 (Windows)/LIST]
    Description:

    • Suggestion for code change in Panel.js 'Ext.form.Panel',

      setRecord(record) cause events to fire prior to actually setting the record


    Test Case (current code) :

    Code:
        /**
         * Loads matching fields from a model instance into this form.
         * @param {Ext.data.Model} instance The model instance.
         * @return {Ext.form.Panel} This form.
         */
        setRecord: function(record) {
            var me = this;
     
            if (record && record.data) {
                me.setValues(record.data); // RJR 030913 causing events to fire before record has been set!
            }
     
            me._record = record;  
     
            return this;
        },
    Possible fix:
    Code:
     
    
        /**
         * Loads matching fields from a model instance into this form.
         * @param {Ext.data.Model} instance The model instance.
         * @return {Ext.form.Panel} This form.
         */
        setRecord: function(record) {
            var me = this;
     
            me._record = record; // RJR 030913 set _record prior to setValues(_)
     
            if (record && record.data) {
                me.setValues(record.data);
            }
     
            //RJR 030913  
            //me._record = record;  
     
            return this;
        },

    Operating System:
    • windows 8

  2. #2
    Sencha - Senior Forum Manager mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    37,330
    Vote Rating
    846
    mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute

      0  

    Default


    I honestly don't know why we would use setRecord and not use updateRecord for this.
    Mitchell Simoens @SenchaMitch
    Sencha Inc, Senior Forum Manager
    ________________
    Check out my GitHub, lots of nice things for Ext JS 4 and Sencha Touch 2
    https://github.com/mitchellsimoens

    Think my support is good? Get more personalized support via a support subscription. https://www.sencha.com/store/

    Need more help with your app? Hire Sencha Services services@sencha.com

    Want to learn Sencha Touch 2? Check out Sencha Touch in Action that is in print!

    When posting code, please use BBCode's CODE tags.

  3. #3
    Sencha User
    Join Date
    Oct 2012
    Posts
    3
    Vote Rating
    0
    rjrempe is on a distinguished road

      0  

    Default panel.js setRecord implementaion

    panel.js setRecord implementaion


    I understand doing the 'setValue(record.data)' to populate the form's 'fields'; but some of those 'fields' will fire changed/updated events.

    In my case, these events are routed to a controller which evaluates data in the form's current record - which has not yet been set.

    Current work-around is a base class for my panels which controls events being fired during 'setRecord' thus:

    config:
    {
    uiActiveOnSetRecord: false
    },
    setRecord : function(record)
    {
    if (_uiActiveOnSetRecord) {
    this.callParent(arguments);
    }
    else {
    this.suspendEvents();

    this.callParent(arguments);

    this.resumeEvents();
    }
    },

    This seems to work ok - but I dislike adjusting a framework in which I do not consider myself expert...

Thread Participants: 1

Tags for this Thread