首页 > 解决方案 > 组合框中的零而不是 NULL (ExtJS 4.2)

问题描述

我正在使用旧版本的 ExtJS (4.2),并且在我的应用程序中的一个编辑表单中添加了一个组合框。

组合框如下所示:

Ext.define('RgiApp.view.ImjestoTipObjektaCombo2', {
extend: 'Ext.form.field.ComboBox',
alias: 'widget.imjestoTipObjektaCombo2',
requires: 'RgiApp.store.ImjestoTipObjektaStore2',
fieldLabel: 'Vrsta obilježja II',
name: 'vrstaobiljezjaid2',
displayField: 'name',
valueField: 'id',
matchFieldWidth: true,
queryMode: 'local',
forceSelection: false,
typeAhead: true,
minChars: 2,
//listWidth: 200,
//width: 200,
//minListWidth : 200,
store: 'RgiApp.store.ImjestoTipObjektaStore2'
});

组合框填充了来自数据库的记录,并且工作正常,但是当我编辑该字段中包含 NULL 值的记录时,该值设置为零(下图)。

在此处输入图像描述

如果存在 NULL 值,我希望组合框为空,因此如果保留则提交 NULL。这样,我必须在提交表单之前手动删除零。

编辑:

我在组合框中添加了emptyText属性,现在如果我创建新记录,表单将包含该文本,但当我编辑时它仍然为零。这些值在数据库中为 NULL。

标签: javascriptextjs4

解决方案


尝试将 emptyText 属性添加到您的组合框定义中。Ext.form.field.Text-cfg-emptyText Combobox 继承自 Text field 控件。


推荐阅读