默认[PXDBInt]数据字段为空值吗? [英] Default [PXDBInt] data field to Null value?

查看:69
本文介绍了默认[PXDBInt]数据字段为空值吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何让数字字段允许并默认为Null /未指定值?

How can I have a numeric field allow and default to a Null / unspecified value?

当我将此字段的控件添加到屏幕上时,它在新实体上始终默认为 0 ...

When I add the control for this field to the screen it always defaults to "0" on new entities...

[PXDBInt]
[PXDefault(TypeCode.DBNull, "", PersistingCheck=PXPersistingCheck.Nothing)]
[PXUIField(DisplayName="Nullable Int")]


推荐答案

问题似乎在于该字段是否在窗体区域或网格表中。在网格中,空值将呈现为空单元格,如果保留为空,则将其保留为空值。但是,在表单区域中,将使用 0呈现空值。如果该值被更改,然后尝试将其更改回空/空值,则该值将一直保存到数据库中。

The issue here appears to be whether the field is in a Form area or Grid table. In a Grid a null-value is rendered as an empty cell and persists as null if left empty. However, when in a Form area a null value is rendered with "0". If the value is changed attempting to then change it back to empty/null results in a zero value persisting to the database.

我找到的解决方案是创建控件时使用PXNumberEdit类型字段,将其更改为PXTextEdit字段并将TextMode属性设置为 Number的方法可以达到预期的效果。空值将呈现为空,并与实际的零值区分开。

The solution I found was when creating the control instead of using a PXNumberEdit type field, changing it to a PXTextEdit field and setting the TextMode property to "Number" gave the desired effect. Null values would render as empty and are distinguished from actual zero values.

这篇关于默认[PXDBInt]数据字段为空值吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆