在表单上提交数据转到网格

时间:2014-11-07 13:58:50

标签: forms extjs grid

我正在使用表单和网格面板。表单接收一些数据,单击表单上的添加按钮后,数据应转到网格面板表示它将添加到网格中。我有一些代码但没有工作。

Ext.onReady(function(){

var addUserData = [        
{
    Utype: "Admin",
    Uname: "Jacob",
    Uemail : "adminjacob@gmail.com",        
},];

Ext.define('AddUsersModel', {    
    extend: 'Ext.data.Model',
    fields: ['Utype', 'Uname', 'Uemail']
});

var addUserStore = Ext.create('Ext.data.Store', {
                data : addUserData,
                model : 'AddUsersModel'  
    });
var added_users = Ext.create('Ext.grid.Panel', {

    id:'addUsersID',        
    store: addUserStore,        
    border:0,
    columns: 
    [   {
            text : '<span class="cb_head">Type</span>',
            dataIndex: 'Utype',     

            flex : 1,            

        },{
            text: '<span class="cb_head">Name</span>',
            dataIndex: 'Uname',

            flex : 1,     
        },{
            text: '<span class="cb_head">Email</span>',
            dataIndex: 'Uemail',
            flex : 1,   

        }
    ],
    stateId: "added_users_state_id", 
    stateful: true, 
    stateEvents: ['columnresize', 'columnmove', 'show', 'hide' ], 
});    
added_users.render('added_users');

var empType = Ext.create('Ext.data.ArrayStore', {
    fields: ['searchopt'],
    data : [['Admin'],['Trader']],
    id:'CUSTOMERitems',
});
var add_user    =   Ext.create('Ext.form.Panel', {


    bodyPadding: 5,
    id:'addUserID',

    defaultType: 'textfield',
    items: [{
            xtype: 'combobox',
            fieldLabel: 'Employee Type',
            emptyText : 'Select type',
            id:'emptype',
            name: 'type',
            allowBlank: false,
            typeAhead: true,
            triggerAction: 'all',
            selectOnFocus:true,
            store: empType,
            queryMode: 'local',
            displayField: 'searchopt',
            valueField: 'searchopt',
            listeners: {
                beforequery: function (record) {
                    record.query = new RegExp(record.query, 'i');
                    record.forceAll = true;
                }
            }            
        },{
            fieldLabel: 'Name',
            emptyText : 'Name',
            name: 'name',
            allowBlank: false
        },{
            fieldLabel: 'Email',
            name: 'email',
            emptyText : 'Email',
            allowBlank: false,
            width:170,
        },{               
            fieldLabel: 'City',
            emptyText : 'City',
            name: 'city',
            allowBlank: false
        },{            
            fieldLabel: 'Zip',
            emptyText : 'Zip',
            name: 'zip',
            allowBlank: false
            },
    ],


    buttons: [ {
        text: 'Add',
        handler: function(form,grid,store) {
        }
    }],

});
add_user.render('add_user');

});

任何人都可以帮助我吗?

亲切的问候,

1 个答案:

答案 0 :(得分:0)

您可以尝试将autoLoad的值设置为true

 var addUserStore = Ext.create('Ext.data.Store', {
                    data : addUserData,
                    model : 'AddUsersModel',
                    autoLoad: true
        });