Results 1 to 4 of 4

Thread: Binding form to json data

  1. #1
    Touch Premium Member
    Join Date
    Dec 2010
    Posts
    55
    Vote Rating
    0
      0  

    Question Binding form to json data

    Hi guys,
    How do we bind forms to json data directly, without having to manually set each form field to appropriate json property we receive? I supposed it should match the name of the form field with json property names, but that does not work. I found some example in a book, but i dont get it, because according to book it should work, and it doesn't work for me.

    Code:
        Ext.onReady(function () {
            var form = new Ext.FormPanel({
                applyTo: 'details-form',
                title: 'Form 1',
                frame: true,
                width: 320,
                height: 200,
                items: [{
                    xtype: 'textfield',
                    name: 'Name',
                    id: 'Name',
                    fieldLabel: 'Company name'
                }]
            });
    
            form.on({
                actioncomplete: function (form, action) {
                    if (action.type == 'load') {
                        var data = action.result.data;
                        form.setTitle(data.Name + ' - Details');
                    }
                }
            });
    
            form.load({ url: 'http://localhost:55284/DataStore/GetStoreJSON/30', waitMsg: 'Loading store details...' });
        });
    Also, this actioncomplete event is not firing.

    Any help would be very much appreciated.

  2. #2
    Touch Premium Member
    Join Date
    Dec 2010
    Posts
    55
    Vote Rating
    0
      0  

    Default

    I realized I should wrap the json data inside an object { success:true, data: my_data }, but i still couldnt find anything about the actioncomplete event.

  3. #3
    Sencha - Sr Software Engineer mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    39,553
    Vote Rating
    1272
      0  

    Default

    There are two things a FormPanel actually has...

    1. The actual Panel that renders everything (fields and such).
    2. And BasicForm which handles loading/submitting.


    BasicForm has the actioncomplete event and to get the BasicForm you just have to execute the getForm method on the FormPanel and it will return the BasicForm.
    Mitchell Simoens @LikelyMitch
    Sencha Inc, Senior Software Engineer
    ________________
    Learn BBCode and use it! Checkout the CODE tag!

    Check out my GitHub, lots of nice things for Ext JS and Sencha Touch
    https://github.com/mitchellsimoens

  4. #4
    Touch Premium Member
    Join Date
    Dec 2010
    Posts
    55
    Vote Rating
    0
      0  

    Default

    i see, thanks a lot!

Similar Threads

  1. Having a Grid inside a Form and load data from one JSON data source!
    By behrooz_a in forum Ext 3.x: Help & Discussion
    Replies: 2
    Last Post: 6 Jan 2011, 3:26 AM
  2. Data binding Form to grid
    By chiconerd in forum Ext 3.x: Help & Discussion
    Replies: 15
    Last Post: 20 Oct 2010, 6:21 AM
  3. Saki Examples: Complex Data Binding with JSON
    By Tumac in forum Ext 3.x: Help & Discussion
    Replies: 2
    Last Post: 5 Jan 2010, 11:20 AM
  4. [2.1] Data Binding Grid -> Form
    By orangehairedboy in forum Ext 2.x: Help & Discussion
    Replies: 4
    Last Post: 23 Jun 2008, 7:09 AM
  5. Form data binding
    By ishafe in forum Ext GWT: Help & Discussion (1.x)
    Replies: 1
    Last Post: 4 Jun 2008, 5:44 PM

Tags for this Thread

Posting Permissions

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