Results 1 to 7 of 7

Thread: Populating form field with data from second datasource based on first

  1. #1

    Default Populating form field with data from second datasource based on first

    I have a grid that loads data from ds just fine and dandy. What I need to do, is when the user clicks on the row, I need to send a variable back to PHP and query the db to return the result. I have this done via a listener and have ds2 load when user selects a row. But the second datastore form population isn't working. I can't really add the ds2 record to the first because they come from separate tables that do not have the same schema. I've been looking at this code, searching the forums, and going through the learning center/faqs for the past three hours. If someone could just tell me why I would be extremely thankful. Thank you!

    Note: Firebug console: The ds2 does load. Now I need to access that data in the form. Should I do a drill-down for the form? ds2.sfein.value?

  2. #2
    Sencha User Condor's Avatar
    Join Date
    Mar 2007
    Location
    The Netherlands
    Posts
    24,246

    Default

    I would recommend loading the second store first and then combine the data from the 2 records and load the form with that, e.g.

    Code:
    rowselect: function(sm, row, rec) {
    	var xyz = rec.get("FEIN");
    	ds2.load({
    		params: {fei: xyz},
    		callback: function(records, options, success) {
    			if (success) {
    				var data = Ext.apply(Ext.apply({}, rec.data), records[0].data);
    				Ext.getCmp("company-form").getForm().setValues(data);
    			}
    		}
    	});
    }

  3. #3

    Default

    Thanks for your prompt reply Condor. I'm going to try your code, but before I do, a quick question. Would I not need to get the record of the first ds in order to apply it to the second? The second is dependent upon a value retrieved from the first. Then again, I haven't tried it, so I will take a looksie right now.

    Thank you again!

  4. #4

    Default

    Hi,

    Condor, thanks for your suggestion, but it doesn't work. I'm using an Oracle db and it throws errors about missing the variable retrieved from the clicked ds record. However, I'm going to see if I can tweak it to make it work. Thanks for your help.

  5. #5

    Default

    Alrighty then, I've identified and fixed the aforementioned error. Now, for something new. The console throws the error : Ext.getCmp("company-form").getForm().loadData(data); is not a function, so I tried Ext.getCmp("company-form").getForm().load(data); and in the Firebug console, it correctly lists the corresponding data for mainframe.php and the records for the other table. However, the form is not populated at all. Do I need to call a FormPanel.load(data)?

    All help is appreciated. Thank you.

  6. #6
    Sencha User Condor's Avatar
    Join Date
    Mar 2007
    Location
    The Netherlands
    Posts
    24,246

    Default

    Me bad... It should be setValues() and not loadData().

  7. #7

    Default

    Condor, you are a wonderful person! It works in Firefox, but in IE it gives the error records[0] is undefined. I do have a single record that does not have a correlating relationship between tables. I'll see what I can do about that. Thank you SO much!

Posting Permissions

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