Extjs Uncaught TypeError on loading items in form panel

99 views Asked by At

I want to add some form items from a json array to a form panel. But I'm getting this error "Uncaught TypeError: this.getView(...).getStore is not a function". But this function is declared inside the controller below. I don't now how to fix it.

View:

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);

Controller:

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

There are 0 answers