在表单面板中加载项目时Extjs Uncaught TypeError

时间:2015-06-18 13:58:48

标签: extjs extjs4

我想将一些表单项从json数组添加到表单面板。但我收到此错误“Uncaught TypeError:this.getView(...)。getStore不是函数”。但是这个函数在下面的控制器中声明。我现在不知道如何解决它。

查看:

Ext.define('myApp.viewForm', {
extend: 'Ext.form.Panel',
 xtype: 'form',

controller: "form,

viewModel: {
    type: "form"   
},

title: 'form',
bodyPadding: 10,
autoScroll: true,

defaults: {
    anchor: '100%',
    labelWidth: 100
},

reconfigure: function(data) {                
    var me = this;
    Ext.each(data, function(item, index) {
        console.log(item) ;
        me.add(item);
    });
}
});

// create form and add store 
var form = Ext.create('myApp.view.Form', {
    renderTo: Ext.getBody(),
    store: new myApp.store.Forms()
});

// Mocking the loading of data and firing of 'metachange' event
var mockData = {
"data": [{
    "name": "ff",
    "xtype": "textfield",
    "allowBlank": false,
    "fieldLabel": "labelText1"
}, {
    "name": "fsdsdf",
    "xtype": "textfield",
    "allowBlank": false,
    "fieldLabel": "labelText2"
}]
};
form.getStore().fireEvent('metachange', form.getStore(), mockData);

控制器:

Ext.define('myApp.view.FormController', {
extend: 'Ext.app.ViewController',
alias: 'controller.form',

init: function(application) {
    this.getView().getStore().on("metachange", this.handleStoreMetaChange, this);
},

handleStoreMetaChange: function(store, meta) {
    this.getView().reconfigure(meta.data);
}
});

0 个答案:

没有答案