我是ExtJS的新手,我在Sencha论坛上遇到了类似的问题,但尚未解决。

This is the link to the problem

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

最佳答案

我不认为您对代码事情是正确的……但是无论如何,这个家伙的代码是一团糟,米歇尔已经回答了应该怎么做。因此,请稍等片刻,而无需理会该家伙的代码,因为将其存档非常简单。

这是一个如何完成此工作的方法:

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":"lisa@simpsons.com",  "phone":"555-111-1224"  },
        { 'name': 'Bart',  "email":"bart@simpsons.com",  "phone":"555-222-1234" },
        { 'name': 'Homer', "email":"home@simpsons.com",  "phone":"555-222-1244"  },
        { 'name': 'Marge', "email":"marge@simpsons.com", "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);
            }
  //....

07-24 09:50
查看更多