Below is some code that works after one button click. When I set that "view" variable again in another button click (for a different button) and run this exact code with a different grid and a different form, the two items disspapear completely. Why does it run on the first iteration, but not the second?
More importantly, how can I switch the components for these two items the correct way? I've tried using the "itemId" config in these two components (via getComponent), I've tried using the "id" config in these components (via getCmp) and I've tried using the "items" object from the parent component of these two items. I was unsuccessful. The only way I could get it to work (at least on the first button click) was with the "region" config (see below).
Function called after button click:
openAssociationGrid : function() {
var view = this.getViewportAdmin();
var main = view.down('[region=west]');
main.removeAll();
main.add({
region: 'center',
itemId: 'grid',
xtype: 'view-association-grid',
width: '50%',
store: 'Associations',
split: true
});
main.add({
region: 'east',
itemId: 'form',
xtype: 'view-association-form',
width: '50%',
split: true
});
},
EDIT:
Per @Thevs answer, I've got this code. How do I apply it to replace a given item in an items array for a view?
var id1 = Ext.id();
alert(id1);
var id2 = parseInt(id1.replace("ext-gen", ""));
alert(id2);
I've tried the following, and does not work yet. I'd prefer to use the id, and not these border layout regions, since I may change the layout in the future to vbox or hbox or a combination of both.
var view = this.getViewportAdmin();
var center = view.down('[region=center]');
var east = view.down('[region=east]');
Ext.apply(center, {
region: 'center',
itemId: Ext.id(),
xtype: 'view-property-grid',
width: '50%',
store: 'Properties',
split: true
});
Ext.apply(east, {
region: 'east',
itemId: Ext.id(),
xtype: 'view-property-form',
width: '50%',
split: true
});