Results 1 to 3 of 3

Thread: FormPanel record object

  1. #1
    Ext User
    Join Date
    Nov 2008
    Location
    Oakland, CA
    Posts
    155

    Default FormPanel record object

    I am trying to figure out how to get access to the record object of the FormPanel. I use the following code to load the FormPanel from a JsonStore on load. I want to be able to pass the record.id value to the params collection when I submit the form. I can't find any way to do this.

    Here is the FormPanel being loaded from the JsonStore.
    Code:
    var jsonStore = new Ext.data.JsonStore({
        url: '/Bug/GetBugs',
        totalProperty: 'totalRows',
        root: 'rows',
        id: 'PKId',
        fields: [
            'PKId',
            to many fields to list...
        ],
        listeners: {
            load: function(store, records, options) {
                try {
                    var record = store.getAt(0);
                    var form = Ext.getCmp('mainForm');
                    if (form)
                        form.getForm().loadRecord(record);
                } catch(err) {
                    console.log(err);
                }
            },
            loadexception: function(store, options, response, e) {
                console.log(e);
            }
        }
    });
    Here is the submit function on the FormPanel.
    Code:
    buttons: [{
        text: 'Save',
        handler: function() {
            Ext.getCmp('mainForm').getForm().submit({
                url: '/Bugs/Edit', // The REST based url that the data will be saved to.
                method: 'POST',
                params: { id: '10' },
                waitTitle: 'Processing...',
                waitMsg: 'Please wait...'
            });
        }
    }]
    I would like to pass something like selectedRecord.id in place of the value '10' which is some made of value for testing. Is it possible to get access to the record which is bound to the form?

  2. #2
    Sencha User nomack84's Avatar
    Join Date
    Oct 2007
    Location
    Quito, Ecuador
    Posts
    200

    Default

    I you take a look at the source code, you'll see that a form have no record defined inside. When you do some load record or something that using a record, what the method do is take the record data property, and them iterate throw all that propertys, and make setValues to each form's field.

    It's clear enouth?

    Sorry if there are any mistake in my languaje.
    Ext is terrific!!

  3. #3
    Ext User
    Join Date
    Nov 2008
    Location
    Oakland, CA
    Posts
    155

    Default

    OK, I think what I take from your answer is that I don't have access to the record that has been loaded into the form. So what I am going to do is create a new variable to store the currently selected record when it's loaded from the store. I can then use the currentRecord variable in my submit event.

    Thanks for helping me think about this!

Posting Permissions

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