Results 1 to 2 of 2

Thread: Good approach to load a fairly complicated form from one lookup

  1. #1
    Ext JS Premium Member
    Join Date
    Apr 2009
    Posts
    4

    Default Good approach to load a fairly complicated form from one lookup

    Hi all,

    I've got a fairly complicated customer order form:
    Full name, (First, MI, Last)
    preferred and alternate shipping address,
    phones (fax, mobile, main),
    email... etc...
    Now, assuming that all my customer information is stored in a DB, what I'd like to be able to do is this:
    If you type in the phone number, the rest of the fields populate.
    If you type in the name, the rest of the fields populate.
    If you type in the street address, the rest of the fields populate.
    You get the idea. In cases where there's non-unique results, I want to use an iPhone-Maps style popup that asks for clarification if there are ambiguities...

    Now I already have a datastore up and working that will populate combobox for the name set to fire after 4 characters... and I'm getting the record id for the customer based on the selection of the combobox... the question is, how do I use that "id" to load all the other fields on the form?

    Do I just write a new action or something for the on.select method of the combobox that goes out, hits the database, retreives a JSON string with all the fields, and then busts it open and sticks the proper values into the proper fields? That's easy enough.... however.

    I'd like to be able to use just about any field on the form for the "lookup" that would (or could) return the record id for the customer, and then have a more generic function that takes the "id" as an argument and then performs the lookup and then populates all the fields automatically...

    I'm thinking: if I match the column names of the customer record to each of the Ext "id" fields on the panel, then I could just go through the JSON and stick the values into each field on the form using somekind of Ext.lookup to get the id of the Ext field (which is the same as the column name in the db) and set the value.

    Am I being Nave? Is there much more to it than that?

    -C.

  2. #2
    Sencha Premium Member
    Join Date
    Dec 2007
    Posts
    38

    Default

    Once you load the data you can use formpanel.getForm().loadRecord or formpanel.getForm().setValues to set the field values. No need to do the lookup of the fields yourself.

Similar Threads

  1. Replies: 6
    Last Post: 19 May 2009, 8:15 AM
  2. Form lookup fine in FF but messup in IE
    By hiral in forum Ext 2.x: Help & Discussion
    Replies: 0
    Last Post: 11 Jul 2008, 12:30 AM
  3. Replies: 4
    Last Post: 19 Jun 2008, 11:26 AM
  4. How to load a form with a record lookup
    By kstevens in forum Ext 2.x: Help & Discussion
    Replies: 0
    Last Post: 30 Apr 2008, 8:32 AM
  5. Replies: 1
    Last Post: 10 Mar 2008, 8:53 PM

Posting Permissions

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