Results 1 to 2 of 2

Thread: Load data from Servlet to Grid in a Form

  1. #1
    Sencha User
    Join Date
    Apr 2013
    Posts
    6

    Default Answered: Load data from Servlet to Grid in a Form

    Hello,

    I have a form with textfields and grids on it. I have populated data in the textfields from servlet by using the code below that is in my controller.

    Code:
    view.down('form').loadRecord(record);
    Is there any way to populate data to the grids? I tried passing the data from controller to view and it properly worked by using the code below.

    Controller:
    Code:
    var comboTopics = Ext.create('tdo.store.Topics',{
                     fields: ['topicCode'],
                     data : [
                        {"topicCode":"AP-018"},
                        {"topicCode":"FIN-004"},
                        {"topicCode":"GEN-013"}
                    ]
                    
                    });
    var view = Ext.create('tdo.view.trngRecords.Edit',{id:Ext.id(),topics:comboTopics})
    View:
    Code:
    initComponent: function() {
        this.topics = this.topics;
        console.log(this.topics);
            this.callParent();
        }
    My problem is how can I make this store appear on my grid? and am I on the right track? Please help.

    Code of my grid:

    Code:
    var comboTopics = Ext.create('Ext.data.Store', {
            fields: ['topicCode'],
        });
    Code:
    var topicGrid = Ext.create('Ext.grid.Panel', {
            store: comboTopics,
            columns: [{
                header: 'Topic',
                dataIndex: 'topicCode',
                flex: 1,
                allowBlank: false,
                renderer: function(topicCode) {
                    console.log(topicCode);
                    var index = storeTopics.find('topicCode', topicCode);
                    console.log(storeTopics);
                    console.log(index);
                    return (index === -1) ? "" : storeTopics.getAt(index).get('topicDesc');                
                },
                editor: {
                    xtype: 'combobox',
                            store: storeTopics,
                            queryMode: 'local',
                            displayField: 'topicDesc',
                            valueField: 'topicCode',
                             forceSelection:true
                        }
            }]
        });

  2. Add a proxy to your store and configure it to read the data coming from your servlet. Then when you load the store it will send the request and display the data automatically.

  3. #2
    Sencha Premium Member
    Join Date
    Nov 2013
    Posts
    160
    Answers
    5

    Default

    Add a proxy to your store and configure it to read the data coming from your servlet. Then when you load the store it will send the request and display the data automatically.

Similar Threads

  1. Passing data from grid to servlet upon updation
    By Tom Schildt in forum Ext: Q&A
    Replies: 1
    Last Post: 31 Oct 2013, 7:43 PM
  2. want to show the data from the servlet to grid
    By abhijit.chanda in forum Ext: Q&A
    Replies: 1
    Last Post: 4 Jan 2013, 7:49 AM
  3. to make tree grid by fetching data from servlet
    By Goutam_Parashar in forum Ext: Discussion
    Replies: 0
    Last Post: 8 Jun 2011, 2:04 AM
  4. 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
  5. Read data from servlet to a grid using JSON
    By thara in forum Ext 2.x: Help & Discussion
    Replies: 8
    Last Post: 6 Sep 2009, 1:05 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
  •