Results 1 to 3 of 3

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

    Looks like we can't reproduce the issue or there's a problem in the test case provided.
  1. #1
    Sencha User
    Join Date
    Oct 2012
    Posts
    3
    Vote Rating
    0
      0  

    Default 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 - Sr Software Engineer mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    39,339
    Vote Rating
    1297
      0  

    Default

    I honestly don't know why we would use setRecord and not use updateRecord for this.
    Mitchell Simoens @LikelyMitch
    Sencha Inc, Senior Software Engineer
    ________________
    Learn BBCode and use it!

    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
      0  

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

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •