2013-01-02 92 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