从Extjs 4中的form.getValues()中获得空组合字段值

Get Empty combo field value from form.getValues() in Extjs 4

本文关键字:组合 字段 Extjs 中的 form getValues      更新时间:2023-09-26

我有两个组合框的表单控制(一个是可编辑的),当组合为空时,我无法获得字段值对。

是否有属性表示combo,如果combo被重置为空则发送空值

。E例如:

考虑第一个组合是名称属性为' Country '的国家和

第二个组合是带有名称属性' State '和可编辑属性的State。

状态combo未选中或已选中并已清除

我得到form.getvalue()作为{国家:'xxx'}

但我需要{country:'xxx',state: "}

如何得到这个输出,是否有任何属性的形式或组合?

您需要为该字段提供一个默认值,只需将其设置为空字符串…

value: ''

下面是一个示例(打开firebug控制台,查看getValues()的输出)

http://jsfiddle.net/jaitsu/GLARt/

您可以使用:

    {
        xtype: 'textfield',
        id: 'searchValue',
        value:'' // this way value is empty string
    }

从api文档中form.getValues()的参数列表为:

getValues( [Boolean asString], [Boolean dirtyOnly], [Boolean includeEmptyText] )

按以下方式使用此方法:

form.getValues(false, false, true);

和在提交时启用submitEmptyText : true