@@ -21,19 +21,27 @@ Ext.onReady(function(){
2121
2222 function clearExtjsComponent ( cmp ) {
2323 var f ;
24+ console . log ( cmp . items )
2425 while ( f = cmp . items . first ( ) ) {
2526 cmp . remove ( f , true ) ;
2627 }
2728 }
2829
30+ function replaceComponentContent ( cmpParent , cmpContent ) {
31+ clearExtjsComponent ( cmpParent ) ;
32+ cmpParent . add ( cmpContent ) ;
33+ cmpParent . doLayout ( ) ;
34+ }
35+
2936 var contentPanel = {
3037 id : 'content-panel' ,
3138 region : 'center' , // this is what makes this panel into a region within the containing layout
32- layout : 'card ' ,
39+ layout : 'fit ' ,
3340 margins : '2 5 5 0' ,
3441 activeItem : 0 ,
3542 border : false ,
3643 items : [ {
44+ xtype :'panel' ,
3745 id : 'start-panel' ,
3846 title : 'Start Page' ,
3947 layout : 'fit' ,
@@ -42,6 +50,15 @@ Ext.onReady(function(){
4250 } ]
4351 } ;
4452
53+ var tmpPanel = {
54+ xtype :'panel' ,
55+ id : 'start-panel' ,
56+ title : 'Start Tmp Page' ,
57+ layout : 'fit' ,
58+ bodyStyle : 'padding:25px' ,
59+ html : 'start-div' // pull existing content from the page
60+ } ;
61+
4562 var store = Ext . create ( 'Ext.data.TreeStore' , {
4663 root : {
4764 expanded : true
@@ -55,7 +72,7 @@ Ext.onReady(function(){
5572 var treePanel = Ext . create ( 'Ext.tree.Panel' , {
5673 id : 'tree-panel' ,
5774 title : 'Sample Layouts' ,
58- region :'north' ,
75+ // region:'north',
5976 // split: true,
6077 height : '100%' ,
6178 // minSize: 150,
@@ -65,7 +82,8 @@ Ext.onReady(function(){
6582 } ) ;
6683
6784 treePanel . getSelectionModel ( ) . on ( 'select' , function ( selModel , record , index , eOpts ) {
68- console . log ( contentPanel ) ;
85+ console . log ( selModel ) ;
86+ console . log ( record )
6987 if ( record . get ( 'leaf' ) ) {
7088 // clearExtjsComponent(contentPanel)
7189 /*contentPanel.update('');
@@ -75,25 +93,92 @@ Ext.onReady(function(){
7593
7694 // redraw the containing panel
7795 contentPanel.doLayout();*/
78-
79- dynamicPanel = new Ext . Component ( {
80- loader : {
81- url : 'me.html' ,
82- renderer : 'html' ,
83- autoLoad : true ,
84- scripts : true
96+ // var firstItem = Ext.getCmp('content-panel').items.first();
97+ // Ext.getCmp('start-panel').html = 'Hello World';
98+ // console.log(Ext.getCmp('start-panel'));
99+ // clearExtjsComponent(Ext.getCmp('start-panel'));
100+ // Ext.getCmp('content-panel').removeAll(true);
101+
102+ // Ext.apply(config, attributes);
103+ var node = { params : { clientId : 'clientId' , clientName : 'clientName' , layoutName : "ClientLayout" } } ;
104+
105+ // Ext.apply( config, attri );
106+ // var p = Ext.ComponentMgr.create(config, 'panel');
107+ // console.log(Ext.getCmp('content-panel'));
108+ // console.log(Ext.getCmp('start-panel'));
109+ // console.log(p);
110+ // Ext.getCmp('content-panel').add( config );
111+ // Ext.getCmp('content-panel').doLayout();
112+ // replaceComponentContent(Ext.getCmp('content-panel'), tmpPanel)
113+ // replaceComponentContent(Ext.getCmp('content-panel'), config)
114+ // Ext.getCmp('viewId').remove(Ext.getCmp('content-panel'));
115+ // Ext.getCmp('viewId').add(contentPanel);
116+ // Ext.getCmp('viewId').doLayout();
117+ va = Ext . getCmp ( 'content-panel' )
118+ Ext . Ajax . request ( {
119+ url : record . get ( 'id' ) + '.json'
120+ , success : function ( resp ) {
121+ var config1 = Ext . decode ( resp . responseText ) ;
122+ console . log ( 'ajax success' )
123+ console . log ( this . renderUI ) ;
124+ console . log ( node ) ;
125+ // console.log(callback);
126+ console . log ( config1 ) ;
127+ // this.renderUI.createDelegate(this, [path, node , callback, config1])();
128+ // Ext.bind(this.renderUI, this, [path, node , callback, config1]);
129+ // this.renderUI(path,node,callback,config1);
130+
131+ var attr = {
132+ itemId : node . id
133+ , header : this . showHeader
134+ , screenHeader : this . showScreenHeader
135+ , title : node . text
136+ , iconCls : ( node . attr ) ? node . attr . iconCls : node . iconCls
137+ // ,bodyStyle : "padding:10px"
138+ , autoDestroy : true
139+ } ;
140+ //this.removeAll();
141+ var p = Ext . ComponentMgr . create ( config1 , 'panel' ) ;
142+ //this.add( p );
143+ //this.doLayout();
144+ replaceComponentContent ( Ext . getCmp ( 'content-panel' ) , p ) ;
145+
85146 }
86- } ) ;
87-
88- Ext . getCmp ( 'content-panel' ) . add ( dynamicPanel ) ;
89-
147+ , scope :this
148+ } ) ;
149+ console . log ( 'end select' )
90150 }
91151 } ) ;
92152
153+ var main = new MainPanel ( {
154+ id : "main"
155+ , margins : "5 5 5 0"
156+ , layout : "fit"
157+ , showScreenHeader :false
158+ } )
159+
160+ var sayHi = function ( name ) {
161+ // Note this use of "this.text" here. This function expects to
162+ // execute within a scope that contains a text property. In this
163+ // example, the "this" variable is pointing to the btn object that
164+ // was passed in createDelegate below.
165+ alert ( 'Hi, ' + name + '. You clicked the "' + this . text + '" button.' ) ;
166+ }
167+
168+ var btn = new Ext . Button ( {
169+ text : 'Say Hi' ,
170+ renderTo : Ext . getBody ( )
171+ } ) ;
93172
173+ // This callback will execute in the scope of the
174+ // button instance. Clicking the button alerts
175+ // "Hi, Fred. You clicked the "Say Hi" button."
176+ btn . on ( 'click' , Ext . bind ( sayHi , btn , [ 'Fred' ] ) ) ;
177+
94178 Ext . create ( 'Ext.Viewport' , {
95179 layout : 'border' ,
96180 title : 'Ext Layout Browser' ,
181+ id : 'viewId' ,
97182 items : [ {
98183 xtype : 'box' ,
99184 id : 'header' ,
0 commit comments