extjs 4 网格中的日期列为空

发布于 2025-01-05 22:05:09 字数 425 浏览 2 评论 0原文

我的网格中有一个日期列。有没有办法确保日期值不为空。

即见下图。该字段有一个日期。但是当我双击编辑时,该值被清除。

在此处输入图像描述

{
    id: 'Created',
    text: "Created",
    dataIndex: 'Created',
    xtype: 'datecolumn',
    format: 'd/m/Y H:m',
    width: 150,
    sortable: true,
    field: {
        xtype: 'datefield',
        allowBlank: true,
        format: 'd/m/Y H:m'
    }
},

I have a datecolumn in my grid. Is there a way to ensure than that the date value will not be empty.

ie see the below image. This field has a date. But when i double click to edit the value is cleared.

enter image description here

{
    id: 'Created',
    text: "Created",
    dataIndex: 'Created',
    xtype: 'datecolumn',
    format: 'd/m/Y H:m',
    width: 150,
    sortable: true,
    field: {
        xtype: 'datefield',
        allowBlank: true,
        format: 'd/m/Y H:m'
    }
},

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

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

发布评论

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

评论(1

旧时浪漫 2025-01-12 22:05:09

日期格式中的最后一个“m”指的是月份,如果您希望它指的是分钟,则应该是'd/m/YH:i'。另外,从您的屏幕截图来看,它应该以月份为首 'm/d/Y/ H:i' 除非将来每个月的 2 号都会发生一些事情,例如您的“ 02/08/2012”应该为 2012 年 8 月 2 日。不过要回答您的问题:

请确保您具有模型中定义的格式(看起来可能是这样,因为它在没有编辑器的情况下渲染正常) ),但不能告诉:

// your column model
Ext.define('Whatever', {
    extend: 'Ext.data.Model',
    fields: [
        ...,
        {name: 'Created', type: 'date', dateFormat: 'm/d/Y H:i'},
        ...,
    ]
});

列配置应该是这样的(使用 editor 配置 - 而不是字段):

columns: [..., {
    // date column
    id: 'Created',
    xtype: 'datecolumn',
    header: 'Created',
    dataIndex: 'Created',
    width: 150,
    sortable: true,
    editor: {
        xtype: 'datefield',
        allowBlank: true,
        format: 'm/d/Y H:i',
    }, ...
}]

Your last 'm' in the dateformat refers to the month, it should be 'd/m/Y H:i' if you want it to refer to the minutes. Also by the looks of your screenshot, it should have month first 'm/d/Y/ H:i' unless there is something going on on the 2nd of every month in the future, e.g. your "02/08/2012" is supposed to be 2 August 2012. To answer your question though:

Make sure you have the format defined in the model (it looks like you may because it renders ok without the editor), can't tell though:

// your column model
Ext.define('Whatever', {
    extend: 'Ext.data.Model',
    fields: [
        ...,
        {name: 'Created', type: 'date', dateFormat: 'm/d/Y H:i'},
        ...,
    ]
});

Column config should be something like this (use editor config - not field):

columns: [..., {
    // date column
    id: 'Created',
    xtype: 'datecolumn',
    header: 'Created',
    dataIndex: 'Created',
    width: 150,
    sortable: true,
    editor: {
        xtype: 'datefield',
        allowBlank: true,
        format: 'm/d/Y H:i',
    }, ...
}]
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文