Search code examples
extjsextjs3

ExtJs determine visibility on form load


In Extjs 3.4 I have a fairly large form that is being populated from an ajax call via someForm.getForm().load({url: someplace, etc}) which is working flawlessly. The problem I can't seem to get around though, is that there are several comboboxes and checkboxes that determine if another field is visible and allowBlank.

As per the answer on a similar question I have tried using the actioncomplete event on the form but the fields do not have values at that point. I've also tried using the success event of the load() call but get the same issue.

Is there any other ways of getting this functionality from the form.load() call?

Edit - here is my load call:

var panel = Ext.getCmp('someFormID');
panel.getForm().load({
    method: 'GET',
    url: 'ajax_get_request.aspx?id=' + id,
    success: function (form) {
        // This will error: object is null or undefined
        alert(form.findField('fieldID').getValue());
    }
});

I'm relatively new to Extjs so maybe I'm just missing something here...


Solution

  • Not sure why hooking into success callback of Ext.form.BasicForm.load() fails for you, but I can propose an alternative approach.

    I usually use explicit Ext.Ajax.request() call to load data into Ext.data.Record. Then in request()'s success callback I load data into form using Ext.form.BasicForm.loadRecord(). If you need to act upon loaded values, you can do it in the same callback.

    I do it this way, because I like to have original values from the server stored somewhere aside.