Extjs 4.x:如何将数据从网格传递到弹出窗口 window?

Extjs 4.x : How can i pass the data from a grid to a pop up window?

谁能帮帮我?

如果我将侦听器添加到网格并使用 record.get('dataIndex') 它将 return undefined ...

使用 this.getSelectionModel().getSelection()[0] 我得到选定的行,我将其保存在参数测试系统中。

使用弹出窗口的构造函数 window 我将行对象分配给一个新变量并尝试从行中获取数据..但我没有工作:/

initcomponent: function { var config = {
         boddyPadding: 10,
         width: 1400,
         title: 'Testsystem',
         store: this.store,
         emptyText: 'Currently, no test system avaiable!',
         columns: [
                { header: 'System/Database', dataIndex: 'targetSystem', width: 130 },
                { header: 'Operating System', dataIndex: 'operatingSystem', width: 130 },
                { header: 'Version', dataIndex: 'version' },
                { header: 'Operating System Name', dataIndex: 'operatingSystemName', flex: 1 },
                { header: 'RAM', dataIndex: 'ram' },
                { header: 'Member Of', dataIndex: 'memberOf' },
                { header: 'Is Vm ?', dataIndex: 'isVM' },
                { header: 'MAC', dataIndex: 'mac' },
                { header: 'CPU Count', dataIndex: 'cpuCount' },
                { header: 'HDD', dataIndex: 'hdd' }
           ],
         selModel: new Ext.selection.RowModel({mode: 'SINGLE'}),
         forceFit: true,
         listener: {
           select: function(selModel, record, index, options){
                alert(record.get('targestSystem'));
           }
         },
         tbar: {
              items: [
                 { 
                      text: 'Refresh',
                      handler: function() {
                           this.store.reload();
                      },
                      scope: this
                   },
                 { xtype: 'tbseparator'},
                 { 
                      text: 'Edit',
                      handler: function(btn) {
                           new Inubit.Configuration.Edit({
                                testsystem: this.getSelectionModel().getSelection()[0],
                                modal: true,
                                listeners: {
                                     'close' : function() {
                                          this.store.reload();
                                     },
                                     scope: this
                                }
                           }).show(btn);
                      },
                      scope: this
                 }
              ]
          },

           dockedItems: [{
                xtype:'pagingtoolbar',
                store: this.store,
                dock: 'bottom',
                displayInfo: true,
                displayMsg: '{0} - {1} of {2}',
                emptyMsg: "No records to display",
            }]  
        }

然后弹出 window :

Ext.define('Inubit.Configuration.Edit', {
extend: 'Ext.window.Window',
title: 'Edit',

constructor : function(config) {
 this.testsystem = config.testsystem,
 this.name = this.testsystem.get('TargetSystem');

 alert(this.name),

 Ext.apply(this, Ext.apply(this.initialConfig));
 Inubit.Configuration.Edit.superclass.initComponent.call(this);

} });

我是 extjs 的新手,正在使用 4.2

在您的侦听器中,您只需从记录数据中填充要显示的值。这是示例代码

listener: {
       select: function(selModel, record, index, options){
            alert(record.data.name);
       }
     }

在代码示例中,您可以显示您想要的值而不是名称。我附上小提琴手。 Fiddle 这里我显示的是名字。你不能简单地显示对象。请记住这一点。

使用这个:

listeners : {
    select: function(selModel, record, index, options){
        Ext.create('Ext.window.Window', {
            title: 'windowTitle',
            id: 'newTodoListWindow',
            minHeight: 230,
            minWidth: 230,
            layout: 'fit',
            closable: true,
            cls:'windowPad',
            closeAction: 'destroy',
            defaultFocus:'todoTitle',
            items: [
                    {
                        html:record.data.name
                    }
                ]
         }).show();

   }

我有一个解决方案:

onEdit : function(grid) {
      var rows = this.getSelectionModel().getSelection();
      var row = rows[0];
      if (this.getSelectionModel().hasSelection()) {
           Ext.create('Ext.window.Window', {
                title: 'windowTitle',
                id: 'newTodoListWindow',
                minHeight: 230,
                minWidth: 230,
                layout: 'fit',
                closable: true,
                cls:'windowPad',
                closeAction: 'destroy',
                defaultFocus:'todoTitle',
                items: [
                { xtype: 'textfield',
                grow: false,
                width : 650,
                fieldLabel: 'System/Database',
                anchor: '100%',
                value : row.get('targetSystem')
                }]
             }).show();    

这显示了我需要的新 window 中的信息,感谢大家的帮助! :)