2013-01-02 91 views
1

我是ExtJS的新手,我遇到了Sencha论坛中的一个类似问题,该问题尚未解决。在ExtJS网格项目上打开ExtJS桌面窗口双击

This is the link to the problem

基本上,我想要做的就是打开一个桌面窗口应用模块上显示网格选择的数据。我已经创建了链接上显示的同一个窗口。我们有相同的代码,所以我认为在这里发布我的代码是没有意义的。任何帮助将不胜感激。谢谢。

回答

2

我不认为你是对的代码事情......但无论如何,这家伙的代码是一团糟,mitchel已经回答了应该如何做。所以,暂时忘掉这个人的代码,因为将它归档非常简单。

这里是剪断你如何能做到这样的工作:

Ext.define('Ext.ux.DemoWin', { 
    extend: 'Ext.window.Window', 
    alias: 'widget.demowin', 
    width: 200, 
    height: 200, 
    title: 'demo', 
    initComponent: function() { 
     this.callParent(arguments); 
    }, 
    loadRecord: function(rec) { 
     // simplified - just update the html. May be replaced with a dataview 
     this.update(rec.data.name + ' - ' + rec.data.email); 
    } 
}); 

Ext.create('Ext.data.Store', { 
    storeId:'simpsonsStore', 
    fields:['name', 'email', 'phone'], 
    data:{'items':[ 
     { 'name': 'Lisa', "email":"[email protected]", "phone":"555-111-1224" }, 
     { 'name': 'Bart', "email":"[email protected]", "phone":"555-222-1234" }, 
     { 'name': 'Homer', "email":"[email protected]", "phone":"555-222-1244" }, 
     { 'name': 'Marge', "email":"[email protected]", "phone":"555-222-1254" } 
    ]}, 
    proxy: { 
     type: 'memory', 
     reader: { 
      type: 'json', 
      root: 'items' 
     } 
    } 
}); 


Ext.create('Ext.grid.Panel', { 
    title: 'Simpsons', 
    store: Ext.data.StoreManager.lookup('simpsonsStore'), 
    columns: [ 
     { text: 'Name', dataIndex: 'name' }, 
     { text: 'Email', dataIndex: 'email', flex: 1 }, 
     { text: 'Phone', dataIndex: 'phone' } 
    ], 
    height: 200, 
    width: 400, 
    renderTo: Ext.getBody(), 
    listeners: { 
     // the registration should be done with the control() method of the responsible controller 
     itemclick: function(grid,record) { 
      var win = Ext.widget('demowin').show().loadRecord(record); 
     } 
    } 
}); 

这里还有一个JSFiddle

编辑它适用于Ext.ux.desktop.Module

createWindow : function(){ 
    var desktop = this.app.getDesktop(); 
    var win = desktop.getWindow('grid-win'); 
    if(!win){ 
     win = desktop.createWindow({ 
      // ... 
      loadRecord: function(rec) { 
       this.update(rec.data.name + ' - ' + rec.data.email); 
      } 
    //.... 
+0

有趣的建设:) – A1rPun

+0

@ A1rPun无论如何感谢您的upvote。我认为这是启动此 – sra

+0

感谢您的答复最简单的方法。这段代码看起来更好。我可以看到的唯一区别是,用于显示数据的窗口扩展了'Ext.window.Window'类而不是'Ext.ux.desktop.Module',其中您可以最小化或最大化Extjs中的窗口桌面。我可以用'Ext.window.Window'类来做到吗? – John