You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Acumatica PXGrid中DateTime列如何实现日期时间选择功能?

在Acumatica PXGrid中实现DateTime字段的日期时间选择功能

要让PXGrid里的DateTime字段支持日期和时间选择,需从列编辑器配置、显示格式两个核心部分调整,以下是具体解决方案:

关键调整步骤

  1. 修改PXGridColumn的编辑器配置
    为ReceivedDate列明确指定支持时间选择的编辑器类型,并开启时间模式,同时设置包含时间的显示/编辑格式:

    • EditorType="PXDateTimeEdit":指定使用DateTime编辑器
    • EditorTimeMode="True":启用时间选择功能
    • DisplayFormat="g"和EditFormat="g":设置视图和编辑模式下显示日期+短时间(如2024/05/20 14:30)
  2. 验证DAC字段类型
    确保数据源DAC中的ReceivedDate字段为DateTime类型,未被限制为仅日期:

    [PXDBDateTime]
    [PXUIField(DisplayName = "Received Date")]
    public virtual DateTime? ReceivedDate { get; set; }
    

    避免使用PXDBDate或仅日期相关的属性标注。

修改后的完整PXGrid代码示例

<px:PXGrid ID="myGrid" runat="server" DataSourceID="ds" Style="z-index: 100" 
    Width="100%" Height="150px" SkinID="Details">
    <Levels>
        <px:PXGridLevel DataMember="LineItemsView">
            <RowTemplate>
                <px:PXDateTimeEdit ID="rtReceivedDate" TimeMode="true" runat="server" DataField="ReceivedDate" />
            </RowTemplate>
            <Columns>
                <px:PXGridColumn DataField="Itemname" Width="150" />
                <px:PXGridColumn DataField="Itemdesc" Width="200" />
                <px:PXGridColumn DataField="Qty" Width="100" />
                <px:PXGridColumn DataField="Price" Width="150" />
                <px:PXGridColumn DataField="ReceivedDate" Width="150" 
                    EditorType="PXDateTimeEdit"
                    DisplayFormat="g"
                    EditFormat="g"
                    EditorTimeMode="True" />
            </Columns>
        </px:PXGridLevel>
    </Levels>
    <AutoSize Container="Window" Enabled="True" MinHeight="150" />
</px:PXGrid>

效果说明

调整完成后,编辑ReceivedDate字段时会弹出带时间选择器的DateTime控件,支持选择具体日期和时间;视图模式下也会完整显示日期+时间内容,不再默认仅展示12:00 AM。

内容的提问来源于stack exchange,提问作者sreimer

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.29 19:20:26