首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >ExtJS为隐藏字段赋值

问ExtJS为隐藏字段赋值
EN

Stack Overflow用户
提问于 2018-10-02 20:13:25
回答 2查看 1.9K关注 0票数 0

下面的组合框设置为通过API调用放置一些记录,然后在页面上显示。当用户单击submit时,我需要提交2个值,1) gmiExchangeCode和2) gmiFuturesCode。第一个值通过此表单的字段工作,gmiFuturesCode不用于更新隐藏的表单字段。

代码语言:javascript
复制
}, {
            xtype: 'combo',
            autoLoad: true,
            hideTrigger: true,
            fieldLabel: 'Product',
            displayField: 'gmiDescription',
            valueField: 'gmiExchangeCode',
            submitValue: true,
            name: 'exchange',
            queryMode: 'remote',
            queryParam: 'entry',
            typeAhead: true,
            minChar: 2,
            tpl: new Ext.XTemplate('<tpl for="."><div class="x-boundlist-item" style="border-bottom:1px solid #757575;">{gmiExchangeCode} - {lisaMarket} - {gmiFuturesCode} - {gmiDescription}</div></tpl>'),
            store: {
                fields: ['text', 'value'],
                proxy: {
                    type: 'ajax',
                    url: 'API',
                    reader: {
                        type: 'json'
                    }
                }
            },
            listeners: {
                select: function (combo, record, index) {
                    hidden.setValue(record.get('gmiFuturesCode'));
                }
            }
        }, {
            xtype: 'hidden',
            id: 'futures',
            name: 'futures'
        }, {
EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2018-10-03 08:04:34

没有什么叫做"hidden.setValue()“,您必须使用查询选择器或Ext.getCmp('ObjectID')来获取对象。

下面是一个工作示例小提琴

代码语言:javascript
复制
Ext.create('Ext.form.Panel', {
title: 'test',
width: 400,
height: 300,
renderTo: Ext.getBody(),
items: [{
    xtype: 'combobox',
    reference: 'states',
    publishes: 'value',
    fieldLabel: 'Select State',
    displayField: 'displayField',
    anchor: '-15',
    store: {
        fields: ['valueField', 'displayField'],
        data: [
            ['1', 'MyDisplayValueFor1'],
            ['2', 'MyDisplayValueFor2'],
            ['3', 'MyDisplayValueFor3']
        ]
    },
    minChars: 0,
    queryMode: 'local',
    typeAhead: true,
    listeners: {
        select: function (combo, record, index) {
            console.log(record.get('displayField'));
            Ext.getCmp('futures').setValue(record.get('displayField'));
            Ext.Msg.alert('Alert', 'The hidden Field value from the getter is : ' + Ext.getCmp('futures').getValue());
        }
    }
}, {
    xtype: 'hidden',
    id: 'futures',
    name: 'futures'
}]

})

票数 0
EN

Stack Overflow用户

发布于 2018-10-03 09:03:40

尝尝这个

代码语言:javascript
复制
Ext.getCmp('futures').setValue(record.get('gmiFuturesCode'));
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/52615741

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档