1. #1
    Sencha User
    Join Date
    Mar 2008
    Vote Rating
    manilodisan is on a distinguished road


    Default form.loadRecord seems to have stopped working after upgrading to 4.2.1

    form.loadRecord seems to have stopped working after upgrading to 4.2.1

    I've upgraded my project from 4.0.7 to latest: 4.2.1 and I noticed all my forms stopped loading the record. If I open an update form on some user the form remains blank where in 4.0.7 works.

    I'm using:
    HTML Code:
    var form = Ext.create('Ext.form.Panel', {
    form.on("render", function(form) {    form.loadRecord(win.record);}, this);

    A console.log on the record itself returns:

    constructor {raw: Object, modified: Object, data: Object, hasListeners: HasListeners, events: Object…}
    data: Object
        active: 1
        date_added: Sun Aug 04 2013 19:32:40 GMT+0300 (EEST)
        email: "xxxxxxxxxx@gmail.com"
        id: 1636
        username: "xxxxxxxx"
    __proto__: Object
    events: Object
    hasListeners: HasListeners
    id: "AP.model.User-1636"
    index: 1
    internalId: 1636
    modified: Object
    phantom: false
    raw: Object
    store: constructor
    stores: Array[1]
    __proto__: Object
    I can see the data holding the right values but I don't know why isn't the record loaded in the form. I know I can use the url param on the form itself and load the record but I prefer knowing if something changed in the way one should use loadRecord on a form.

    Much appreciated

  2. #2
    Sencha User carol.ext's Avatar
    Join Date
    Jun 2007
    Littleton, Colorado, USA
    Vote Rating
    carol.ext has a spectacular aura about carol.ext has a spectacular aura about



    There are some comments in the Ext.form.Basic.loadRecord documentation that seem relevant. They both have suggested solutions. I looked at the source code from 4.0.7 and 4.2.1 documentation links and see the change mentioned below.

    I didn't try either of these solutions.

    Attention! In Ext 4.1.3, loadRecord function looked like this: return this.setValues(record.data); which allows us to pass an object built from the server with no Ext.data.model associated with to fill the form.

    But now, loadRecord function is: return this.setValues(record.getData()); so we have to pass a record that is a Ext.data.Model and it doesn't work anymore with an object having a "data" property...poor it was so useful when you aren't be able to build a data model manually cause of too complex structure...

    Edit: If myObject is an object with a property "data" that is an array containing the list of key/pair values You can use .getForm().setValues(myObject); but the setValues function doesn't set the private "_record" property of the form. So when you call .getForm().getRecord() it will return undefined...

    Workaround: You have to add a function to "myObject": myObject.getData = function (){ return this.data; }

    and like so, you can now call .getForm().loadRecord(myObject); It seems to work again like 4.1.3
    Reply to first comment :
    You are right. In 4.2 edition, when we use "loadRecord(data)" function, ExtJS throwing an error message "getData is not a function". Instead of "loadRecord", when we use "setValues(data)" working properly!
    Last edited by carol.ext; 25 Sep 2013 at 10:02 AM. Reason: Could not see where the second comment started

Thread Participants: 1

Tags for this Thread