Reputation: 18980
I'm trying to pass a custom parameter named "hideButton" to my grid view constructor in Ext JS 4. The framework is throwing an exception of Uncaught TypeError: Cannot read property 'added' of undefined
when I added the "config" and "constructor" configs to my grid view. The alert message does get called. This exception gets called after I hit "OK" on the alert dialog. What is causing this exception?
Ext.define('App.view.ExampleGrid', {
extend: 'Ext.grid.Panel',
xtype: 'view-grid-3',
config: {
hideButton: false
},
constructor: function(cfg) {
alert('called constructor');
this.initConfig(cfg);
},
...
I'm instantiating the grid view from two different other components using lazy instantiation via the "xtype" config. Here is the component that needs to hide a button in the grid view by calling the constructor.
items: [{
region: 'center',
xtype: 'view-tree-3',
width: '40%'
}, {
region: 'east',
xtype: 'view-grid-3',
store: 'GridStore',
config: {
hideButton: true
},
width: '60%'
}]
Upvotes: 1
Views: 837
Reputation: 4861
Let's just say that you can't use config
blocks with Ext JS 4.x. That is a Touch only feature for the time being.
To add or override config options in derived classes, place the config option right there on the class declaration body:
Ext.define('App.view.ExampleGrid', {
extend: 'Ext.grid.Panel',
hideButton: false,
...
});
When instantiating do the same with instance config:
my grid = new App.view.ExampleGrid({
hideButton: true // Overriding the default for this instance
});
Upvotes: 2