首页 > 解决方案 > extjs 表单、组合和隐藏名称

问题描述

有这个代码。

Ext.define('App.v2.model.Things', { 
    extend: 'App.v2.model.Base'
    ,fields: [{
        name: 'C' 
        ,type:'int'
    },{
        name:'NAME'
        ,type:'string'
    },{
        name:'SHORT_NAME'
        ,type:'string'
    }]
    ,proxy:{
        url:'/data/data1.php'
        ,reader : {
                rootProperty: 'data' 
        },
        extraParams: {
            limit: 1000
        }
    },
    idProperty: 'C'
});

文件模型

Ext.define('App.v2.model.ThingsList', { 
    extend: 'App.v2.model.Base'
    ,fields: [{
        name: 'C' 
        ,type:'int'
    },
     {
            name: 'THING_ID',
            type:'int'
    },
     {
            name: 'ZE',
            type:'int'
    },
     {
            name: 'HS',
            type:'int'
    },
     {
            name: 'THING_NAME',
            type:'string'
    },]
    ,proxy:{ 
        url:'/data/thingsList.php'
        ,reader : {
                rootProperty: 'data' 
        }       
    },
    idProperty: 'C'
});

表单配置

    items: [{
            xtype: 'form',
            bodyStyle: 'border:none',
            defaultType: 'textfield',
            layout: 'fit',
      maindata:  [{
        xtype: 'panel',
        //layout: 'vbox',
        layout: 'vbox',
        id: 'ThingsForm',
        items: [{
                xtype: 'textfield',
                fieldLabel: 'ЗЕ',
                name: 'ZE',
                width: 400,
                allowBlank: false
            },
            {
                xtype: 'textfield',
                fieldLabel: 'HS',
                name: 'HS',
                width: 400,
                allowBlank: false
            },
            {
                xtype: 'combo',
                fieldLabel: 'Thing',
                name: 'THING_ID',
                hiddenName: 'THING_NAME', 
                valueField: 'C',
                displayField: 'SHORT_NAME',
                store : {
                            model:'App.v2.model.Things',
                            autoLoad: true,

                        }               
            }
            //]        
        ]
    }]

}]

加载数据以形成

row = grid.store.getAt(this.conf.grid.getSelectionModel().getCurrentPosition().rowIdx);
form = this.down('form').getForm();
form.loadRecord(row);

都好。表格显示值

更改表格后尝试更新记录

var record = form.getRecord(); // see old values of THING_ID and THING_NAME
record.set(form.getValues()); // see new value of THING_ID and OLD value of THING_NAME

如何更新THING_NAME到已NEW value (TEXT)选中COMBO的记录?

只喜欢描述那里? ExtJS 5 组合框 - 提交值和文本

标签: extjs

解决方案


推荐阅读