Extjs 我无法在EditorGridPanel中添加新记录

Extjs 我无法在EditorGridPanel中添加新记录,extjs,Extjs,我目前在ExtJS3.1.0中教授EditorRidPanel。我设法创建了一个显示城市列表的网格。但是,当我尝试向数据库中添加新记录时,出现了一个问题。当我单击“添加城市”按钮时,什么也没有发生,Firebug显示错误: Uncaught ReferenceError: newCity is not defined Ext.grid.EditorGridPanel.tbar.handlereg02.html: 96 Ext.Button.Ext.extend.onClickext-all-de

我目前在ExtJS3.1.0中教授EditorRidPanel。我设法创建了一个显示城市列表的网格。但是,当我尝试向数据库中添加新记录时,出现了一个问题。当我单击“添加城市”按钮时,什么也没有发生,Firebug显示错误:

Uncaught ReferenceError: newCity is not defined
Ext.grid.EditorGridPanel.tbar.handlereg02.html: 96
Ext.Button.Ext.extend.onClickext-all-debug.js: 27083
h
这是我的代码:

Ext.onReady(function(){

//===== Data Store ================================================== (2)
var store = new Ext.data.Store({
                url: 'city_for_eg01.php',
                reader: new Ext.data.JsonReader({
                root:'rows',
                id:'zip'
            }, [
                'zip',
                'city'
            ]),
            api: {
                    create : 'city_for_eg01.php?action=create',
                    read : 'city_for_eg01.php?action=read',
                    update: 'city_for_eg01.php?action=update',
                    destroy: 'city_for_eg01.php?action=destroy'
                },
            writer: new Ext.data.JsonWriter({
                 writeAllFields: true
                }),
            autoSave: false,
        });
store.load();
//=================================================================== end (2)

var editor = new Ext.form.TextField();

var grid = new Ext.grid.EditorGridPanel({
        renderTo: document.body,
        frame:true,
        title: 'City',
        height:200,
        width:520,
        clickstoEdit: 1,
        store: store,
        columns: [
                    {header: "ZIP", dataIndex: 'zip', editor: editor},
                    {header: "CITY", dataIndex: 'city', editor: editor},
                  ],
        listeners: {
                    afteredit: function(e){e.record.commit();}
      },
        tbar: [{
            text: 'Add City',
            icon: 'images/table_add.png',
            cls: 'x-btn-text-icon',
            handler: function() {
                        Ext.Ajax.request({
                                url: 'city-update.php',
                                params: {
                                            action: 'create',
                                            zip: 'zip'
                                         },
                                success: function(resp,opt) {
                                            grid.getStore().insert(0,
                                            new newCity{
                                                    zip: 'New Zip',
                                                    city: 'New City'    
                                                  })
                                         );
                                            grid.startEditing(0,0);
                             },
                                failure: function(resp,opt) {   
                                                    Ext.Msg.alert('Error','Unable to add city');
                                                  }
                    });
                }
         }]               
    });
});

这是因为没有定义
newCity
函数

您应该能够使其与以下各项协同工作:

new store.recordType(/* values */)
recordType
保存该存储的新
记录的构造函数