Concept : Consider two panels A and B and window C , as in the following example. The buttons on the window switch between the two panels.
var A = new Ext.Panel({ title: 'A' }); var B = new Ext.Panel({ title: 'B' }); var C = new Ext.Window({ layout: 'fit', width: 300, height: 300, items: A, buttons: [ { text: 'Switch to A', handler: function() { C.removeAll(false); C.add(A); C.doLayout(); } }, { text: 'Switch to B', handler: function() { C.removeAll(false); C.add(B); C.doLayout(); } }] }); C.show();
The concept is very simple: add a component, remove it, and add the same instance again.
Problem : Switching from A to B works, but returning to A fails (B remains and A is no longer displayed).
Question : Thinking OOP, I would expect this concept to work. Since this is not the case, and this is a very simple maneuver, how should I think / reflect / design when I try to do this?
I understand that when considering the FormPanel form and other layouts / components, there may be different cases, but there must be a common and correct way for this :)
design concept extjs components
Chau
source share