javascript - 组合框中的零而不是 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。
解决方案
尝试将 emptyText 属性添加到您的组合框定义中。Ext.form.field.Text-cfg-emptyText Combobox 继承自 Text field 控件。
推荐阅读
- html - 使用 Bootstrap 在 10 列网格中拟合任意数量的元素
- python - 尝试访问 Azure Databricks 中的 Azure DBFS 文件系统时出现挂载错误
- c# - 在 Windows 窗体 C# 应用程序中使用报表查看器打印报表时出现问题
- sql - 是否可以在一个函数调用中执行多个替换?
- regex - 不能为空格的字母和空格的正则表达式
- python - 映射日期时间引发 KeyError
- sql-server - SQL Server 中的“生成脚本”在“从 (mydbname) 获取对象列表”时失败
- bash - bash 本机字符串操作显示混乱的输出
- c++ - 为什么这个错误会变成(C2664 error c++ Visual Studio)
- jar - 如何使用 java 11 在类路径中动态加载 jar