1. #1
    Touch Premium Member
    Join Date
    Dec 2010
    Posts
    55
    Vote Rating
    0
    sench23 is on a distinguished road

      0  

    Question Binding form to json data

    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
    sench23 is on a distinguished road

      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 - Senior Forum Manager mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    36,795
    Vote Rating
    834
    mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute

      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 @SenchaMitch
    Sencha Inc, Senior Forum Manager
    ________________
    Check out my GitHub, lots of nice things for Ext JS 4 and Sencha Touch 2
    https://github.com/mitchellsimoens

    Think my support is good? Get more personalized support via a support subscription. https://www.sencha.com/store/

    Need more help with your app? Hire Sencha Services services@sencha.com

    Want to learn Sencha Touch 2? Check out Sencha Touch in Action that is in print!

    When posting code, please use BBCode's CODE tags.

  4. #4
    Touch Premium Member
    Join Date
    Dec 2010
    Posts
    55
    Vote Rating
    0
    sench23 is on a distinguished road

      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

Thread Participants: 1

Tags for this Thread

Turkiyenin en sevilen filmlerinin yer aldigi xnxx internet sitemiz olan ve porn sex tarzi bir site olan mobil porno izle sitemiz gercekten dillere destan bir durumda herkesin sevdigi bir site olarak tarihe gececege benziyor. Sitenin en belirgin ozelliklerinden birisi de Turkiyede gercekten kaliteli ve muntazam, duzenli porno izle siteleri olmamasidir. Bu yuzden iste. Ayrica en net goruntu kalitesine sahip adresinde yayinlanmaktadir. Mesela diğer sitelerimizden bahsedecek olursak, en iyi hd porno video arşivine sahip bir siteyiz. "The Best anal porn videos and slut anus, big asses movies set..." hd porno faketaxi