2012-07-04 111 views
0

我想顯示一個彈出窗口,其中顯示一些值,從PHP服務器文件中獲取。我不知道如何顯示窗口上的項目。在顯示窗口時顯示值

我不知道爲什麼,但是在呈現視圖時控制器中的console.log消息'method call'不會顯示。我認爲這是因爲我添加了click: this.methodcall(只有在點擊按鈕時才被調用,但我希望在渲染視圖時打印日誌語句)

沒有顯示在視圖上,我認爲這是因爲我沒有添加任何代碼在視圖中顯示它。

有人可以幫我解決這個問題嗎?

我彈出窗口查看代碼;

Ext.define('Project.view.user.Popupwin', { 
    extend: 'Ext.window.Window', 
    alias: 'widget.popupwin', 
    layout:'fit', 
    autoShow: true, 
    initComponent: function() { 
     this.store = 'Popupwin'; 
     this.items = [ 
      { 
       xtype: 'form', 
       items: [      
       ] 
      } 
     ];  
     this.callParent(arguments); 
    } 
}); 

STORE

Ext.define('Project.store.Popupwin',{ 
    extend:'Ext.data.Store', 
    model:'App.model.Popupwin', 
    proxy: { 
     actionMethods : {   
      read : 'POST'   
     }, 
     type: 'ajax', 
     url : 'loaddata.php', 
     autoLoad: true 
    } 
}); 

CONTROLLER

Ext.define('Project.controller.Popupwin',{ 
    extend: 'Ext.app.Controller',  
    stores:['Popupwin'], 
    models:['Popupwin'], 
    views:['DoctorView'], 
    init: function(){ 
     console.log('executed');     
     this.control({    
      'popupwin': { 
       click: this.methodcall 
      } 
     });    
     }, 
     methodcall: function() { 
          console.log('method call'); 
      this.getShowPopupwinStore().load(); 
     } 
}); 

模型

Ext.define ('Project.model.Popupwin',{ 
    extend: 'Ext.data.Model', 
    fields:['fname','lanme'] 
}); 

回答

3

窗口沒有點擊事件,所以你不能聽它。

Ext.define('MyWindow', { 
    extend: 'Ext.window.Window', 
    afterRender: function(){ 
     this.callParent(arguments); 
     this.el.on('click', this.fireClick, this); 
    }, 

    fireClick: function(e, t){ 
     this.fireEvent('click', this, e); 
    } 
}); 
+0

我應該在哪裏輸入此代碼。在控制器或視圖? – Illep

+0

在窗口中,這就是爲什麼它叫'MyWindow'... –

+0

好的,但我如何顯示我將從數據庫中獲取的項目? – Illep