extjs形式,组合和隐藏名称

时间:2018-08-06 21:19:31

标签: 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 combobox - submitting both value and text

0 个答案:

没有答案