Results 1 to 3 of 3

Thread: Loading Store into Form Panel textfield's values dynamically from database

  1. #1
    Sencha User
    Join Date
    Sep 2012
    Location
    Hyderabad
    Posts
    7
    Vote Rating
    0
      0  

    Default Loading Store into Form Panel textfield's values dynamically from database

    Am using Form Panel to create a form by using ExtJS 4.1 . And i wanto load the form with values getting from database. So i am getting JsonStore from database with required values like name, email, mobile no etc. So i am getting problem at how to read the values from store and model and how to render those values into textfields values.


    Please can you provide some hints in rendering data into Form Panel text fields from Store.

  2. #2
    Sencha User sword-it's Avatar
    Join Date
    May 2012
    Location
    Istanbul
    Posts
    1,335
    Answers
    124
    Vote Rating
    93
      0  

    Default

    Hi lokendar,

    Try with this code-
    Code:
    Ext.create('Ext.FormPanel', {
        width: 500,
        title: 'Parent Panel',
        afterRender: function() {
            this.superclass.afterRender.apply(this);
            this.mask('Please Wait');
            Ext.Ajax.request({
                url: '/echo/json/',         //Give your url here
                scope: this,
                success: function(data) {
                   this.unmask();
                   FormRecord= Ext.JSON.decode(data.responseText)  // decode your responseText from JSON to object
                    this.getForm().setValues(FormRecord);    // get your formPanel and set form field value
                },
                failure: function() {
                    alert('Load Fail')
                }
            });
        },
        items: [{
            xtype: 'textfield',
            fieldLabel: 'Name'},
        {
            xtype: 'combo',
            fieldLabel: 'Age',
            store: ['15', '25', '35']
        }],
        renderTo: Ext.getBody(),
    });
    sword-it.com, Sencha Developer House in Turkey - Istanbul University Technopark Suite 204.

  3. #3
    Sencha User
    Join Date
    Sep 2012
    Location
    Hyderabad
    Posts
    7
    Vote Rating
    0
      0  

    Default

    Thanks for giving reply..........

    I have tried with given example but i am getting data in below format.

    data format is : {"data":[{"Name":"project1"}]}

    This data format is receiving from my servlet. But is is not rendering the values in text field. So please suggest me in which format i have to provide response for ajax request.

Posting Permissions

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