【问题标题】:how to send value from grid (pop up) to form panel in extjs如何从网格(弹出)发送值到extjs中的表单面板
【发布时间】:2016-09-06 05:46:00
【问题描述】:

单击网格视图中弹出的数据后如何在表单面板中显示数据,我尝试了另一种方法但总是错误, 这是我的网格面板:

var tt = Ext.define('Rendering.view.beli.dataSupplier', {
extend: 'Ext.form.Panel',
//extend: 'Ext.window.Window',
//  xtype: 'beligrid',

alias : 'widget.contatoform',

frame: true,
// id: 'detailPanelis',
title: 'Company data',
bodyPadding: 5,
layout: 'column',
requires: [
    'Ext.grid.*',
    'Ext.form.*',
    'Ext.layout.container.Column'
],

initComponent: function() {
    this.items = [
        {
            columnWidth: 0.65,
            xtype: 'gridpanel',
            reference: 'customerGrid',
            store: 'BeliStore',
            columns : [{
                text: 'Nama',
                dataIndex: 'namaSupplier',
                flex: 1

            }, {
                text: 'Alamat',
                dataIndex: 'address',
                flex: 1

            }],
            listeners: {


                scope: this,
                selectionchange: 'onSelectionChanges'
            }


        }];
    //];
    // });
    this.callParent(arguments);
},

onSelectionChanges: function(model, records) {
        //alert('yuhuuuu');
    var editt = Ext.create('Rendering.view.beli.bg_beli');

    var c =  editt.onSelectionChange(model, records);

}

 });

向表单面板发送数据的功能是

listeners: {
              scope: this,
                selectionchange: 'onSelectionChanges'
            }

这是 onSelectionChanges 的函数:

 onSelectionChanges: function(model, records) {
        //alert('yuhuuuu');
    var editt = Ext.create('Rendering.view.beli.bg_beli');

    var c =  editt.onSelectionChange(model, records);

  }

和表单面板:

var tt = Ext.define('Rendering.view.beli.bg_beli', {
extend: 'Ext.form.Panel',

xtype: 'beligrid',

controller: 'binding-dynamic',
frame: true,

title: 'Company data',
bodyPadding: 5,
layout: 'column',



requires: [
    'Ext.grid.*',
    'Ext.form.*',
    'Ext.layout.container.Column'
],

// In this example, configuration is applied at initComponent time
// because it depends on profileInfo object that is generated for the
// FormGrid instance.
initComponent: function() {
    //Ext.apply(this, {


    this.items = [
        {
            columnWidth: 0.65,
            xtype: 'gridpanel',

            store: 'BeliStore',
            columns : [{
                text: 'Nama',
                dataIndex: 'namaSupplier',
                flex: 1

            }, {
                text: 'Alamat',
                dataIndex: 'address',
                flex: 1

            }],
            listeners: {

                scope: this,
                selectionchange: 'onSelectionChange'
            }


        },{
            columnWidth: 0.35,
            margin: '20 0 0 10',
            xtype: 'form',
            title:'Company detailsss',
            layout: 'anchor',

            defaultType: 'textfield',
            items: [
            {

                name : 'id_supplier',
                fieldLabel: 'id',
                hidden:true
            },{
                fieldLabel: 'Nama Supplier',
                name: 'namaSupplier'

            },{
                    fieldLabel: 'email',
                    name: 'email'

            },{
                    fieldLabel: 'alamat',
                    name: 'address'

            },{
                xtype: 'button',
                text: 'YUY',
                action: 'add'
            }]

        }];
    //];
   // });
    this.callParent(arguments);
},

onSelectionChange: function(model, records) {

    alert('asdasd');


    console.log(records);
    var rec = records[0];
    console.log(rec);
    if (rec) {
       var c = this.getForm().loadRecord(rec);
     //   this.getBeliStoreStore().load();
        console.log(this.getForm().loadRecord(rec));
    }
}

});

我将数据从网格发送到表单面板,在表单面板中接受数据的功能是:

 onSelectionChange: function(model, records) {

    alert('asdasd');


    console.log(records);
    var rec = records[0];
    console.log(rec);
    if (rec) {
       var c = this.getForm().loadRecord(rec);
     //   this.getBeliStoreStore().load();
        console.log(this.getForm().loadRecord(rec));
    }
}

请帮忙,我正在寻找任何参考,但我还没有得到答案,谢谢之前

【问题讨论】:

  • 您在控制台中遇到什么样的错误?还是只是在表格中选择时看不到表格中的行数据?还有,¿ExtJS 的版本?
  • 控制台没有错误,但控制台表单面板(父)数据已接受但表单无法显示数据

标签: extjs


【解决方案1】:

我的建议是修改 this.onSelectionChange 事件的调用或类似 this.on('selectionchange',this.onSelectionChange) 这是 extjs 中调用事件的另一种方式

initComponent: function() {

    var me = this ;

    this.items = [
        {
            columnWidth: 0.65,
            xtype: 'gridpanel',
            reference: 'customerGrid',
            store: 'BeliStore',
            columns : [{
                text: 'Nama',
                dataIndex: 'namaSupplier',
                flex: 1

            }, {
                text: 'Alamat',
                dataIndex: 'address',
                flex: 1

            }],
            listeners: {    
                scope: this,
                selectionchange: me.onSelectionChanges
            }


        }];
    //];
    // });
    this.callParent(arguments);
}

OR

initComponent: function() {
    var me = this ;

    var grid = Ext.create('Ext.grid.Panel', {
                     reference: 'customerGrid',
                     store: 'BeliStore',
                     columns : [{
                         text: 'Nama',
                         dataIndex: 'namaSupplier',
                         flex: 1

                      }, {
                         text: 'Alamat',
                         dataIndex: 'address',
                         flex: 1   
                     }
                    ]});

    me.items = [
        {
            columnWidth: 0.65,
            grid               

        }];       

    grid.on('selectionchange',me.onSelectionChange)

    this.callParent(arguments);
}

http://docs.sencha.com/extjs/4.2.5/#!/example/build/KitchenSink/ext-theme-neptune/#form-grid

【讨论】:

  • this.on('selectionchange',this.onSelectionChange) 是表单面板中的函数但错误,因为如果我更改为 var edit = Ext.create('Rendering. view.beli.bg_beli'); edit.on('selectionchange',edit.onSelectionChange),该函数可以通过,并在表单面板(父)中接受,但不能在表单面板中显示数据..
  • 嗨,只需为您的 hoot 元素添加一个别名,例如“me”并为您的函数添加引用,检查我已经修改了第一个建议
猜你喜欢
  • 2012-06-30
  • 1970-01-01
  • 2015-09-07
  • 2011-02-15
  • 2011-08-06
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多