2012-07-04 113 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