EXTJS 存储存在空值问题 -- useNull:没有影响 -- 帮助吗?

发布于 2024-09-30 07:39:14 字数 1236 浏览 7 评论 0原文

各位,

我有一个由 JSONStore 支持的组合框组件。加载到存储中的数据为组合框的值返回 null。该值是一个整数。 JSON 解码过程是将 null 值转换为零;导致组合框在尝试查找其后备存储中不存在的 pk, 0 时无法呈现。

我找到了 data.Field 对象的 useNull: 配置选项,升级到 3.3.0 Final 并将组合框的 int 值设置为 useNull:true。不幸的是,这根本没有任何影响。解码后的值仍然从空变为零。

关于当 JSON 字段的数据为空时如何不将字段设置为零的任何想法?

这是正在发生的事情的图片。请注意 data: 值为零,但 JSON 值为 null。

谢谢!

(啊!愚蠢的声誉<10,所以我不能直接发布图片。在这里查看:调试图片< /a> )

另外,这是我商店的字段配置:

  fields: [
        {name:"id", type:"int"},
        {name:"occurenceDate", dateFormat: 'Y-m-d\\TH:i:s', type:"date"},
        {name:"docketNumber", type:"string"},
        {name:"courtLocationId", type:"int", useNull:true},
        {name:"assignedOfficerId", type:"int", useNull:true},
        {name:"primaryIncidentTypeId", type:"int", useNull:true},
        {name:"secondaryIncidentTypeId", type:"int", useNull:true},
        {name:"tertiaryIncidentTypeId", type:"int", useNull:true},
        {name:"incidentLocation", type:"string"},
        {name:"summary", type:"string"},
        {name:"personalItemsSeized", type:"string"},
        "supplements",
        "parties",
        "judgeIds"
    ]

Folks,

I have a combobox component backed by a JSONStore. The data loaded into the store is returning null for the combobox's value. The value is an int. The JSON decode process is converting the null value into a zero; causing the combobox to fail to render when it attempts to find the pk, zero that doesn't exist in its backing store.

I've found the useNull: config option for data.Field objects, upgraded to 3.3.0 Final and set my int value for the combobox to useNull:true. This isn't having any affect at all, unfortunately. The decoded value is still being changed from null to zero.

Any ideas about how to not set the field to a zero when the data for a JSON field is null?

Here's a pic of what's going on. Notice the data: value is zero, but the JSON value is null.

Thanks!

(gah! stoopid reputation < 10 so I can't directly post the pic. View it here: debug pic )

Also, here's my store's field config:

  fields: [
        {name:"id", type:"int"},
        {name:"occurenceDate", dateFormat: 'Y-m-d\\TH:i:s', type:"date"},
        {name:"docketNumber", type:"string"},
        {name:"courtLocationId", type:"int", useNull:true},
        {name:"assignedOfficerId", type:"int", useNull:true},
        {name:"primaryIncidentTypeId", type:"int", useNull:true},
        {name:"secondaryIncidentTypeId", type:"int", useNull:true},
        {name:"tertiaryIncidentTypeId", type:"int", useNull:true},
        {name:"incidentLocation", type:"string"},
        {name:"summary", type:"string"},
        {name:"personalItemsSeized", type:"string"},
        "supplements",
        "parties",
        "judgeIds"
    ]

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

老娘不死你永远是小三 2024-10-07 07:39:14

尝试在没有类型声明的情况下使用它。您还可以使用转换方法:

{
    name: "primaryIncidentTypeId", 
    convert: function(value, row) {
        return (value == null) ? null : parseInt(value);
    }
}

Try using it without type declaration. You may also use convert method:

{
    name: "primaryIncidentTypeId", 
    convert: function(value, row) {
        return (value == null) ? null : parseInt(value);
    }
}
九八野马 2024-10-07 07:39:14

关于组合宽度:我通常

defaults: {
    anchor: '100%'
}

在表单声明中使用,并且宽度没有问题。

难道不能从服务器端与所有其他元数据一起提供转换功能吗?

我仍在使用 ExtJS 3.2 - 生产系统中不需要任何新错误:)

About the combo width: I usually use

defaults: {
    anchor: '100%'
}

in the form declaration and have no problems with widths.

Isnt't it possible to provide convert functions from server side together with all other metadata?

And I'm still using ExtJS 3.2 - no need of any new bugs in the production systems :)

他不在意 2024-10-07 07:39:14

这也吸引了我,您还可以重写 Ext.data.Types 中的类型转换函数,以允许整数类型字段为空值。

Ext.data.Types.INT.convert = function(v){
  v = parseInt(String(v).replace(Ext.data.Types.stripRe, ''), 10);
  return isNaN(v) ? null : v;
};

This also got me, you can additionally override the type convert function in Ext.data.Types to allow null values for integer type fields.

Ext.data.Types.INT.convert = function(v){
  v = parseInt(String(v).replace(Ext.data.Types.stripRe, ''), 10);
  return isNaN(v) ? null : v;
};
初雪 2024-10-07 07:39:14

您必须使用 defaultValue: null ,useNull : true 因为 integet 类型的默认值为零

示例:

{name:"primaryIncidentTypeId", type:"int", useNull:true , defaultValue: null },

You must use defaultValue: null ,useNull : true because default value for integet type is zero

Example:

{name:"primaryIncidentTypeId", type:"int", useNull:true , defaultValue: null },
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文