【问题标题】:Grid Field blank until edited网格字段空白,直到编辑
【发布时间】:2019-07-24 23:49:09
【问题描述】:

我有一个继承自 PXCustomSelectorAttribute 的自定义选择器。每当我在网格列中使用它时,该字段都会显示为空白,直到单击该字段,就好像要更改它一样。然后现有的保存值在编辑器中正常显示。离开网格单元后,该值再次消失。

我准备了一个非常简化的测试来产生这种行为,并确认“AutoRefresh”属性设置为 true,如类似帖子中所述。

如上图所示,数据记录使用自定义选择器作为其“选项 ID”,并且所有三个记录在 DB & DAC 中都有值。 Selector 确实显示了从 GetRecords() 方法返回的选项。但在单击字段之前,字段值不会显示在网格中。

示例代码:

using System;
using System.Collections;
using PX.Data;

namespace CustomSelectorTest
{
    // The DAC for the detail records
    [Serializable]
    public class TestDAC : IBqlTable
    {
        [PXDBString(IsKey = true)]
        [PXUIField(DisplayName = "Option ID")]
        [PXDefault]
        [CustomSelectorTest]
        public virtual string OptionID { get; set; }
        public abstract class optionID : IBqlField { }

        // An arbitrary data field for testing
        [PXDBString]
        [PXUIField(DisplayName = "User Data")]
        public virtual string UserData { get; set; }
        public abstract class userData : IBqlField { }
    }

    // The DAC for the options presented through the custom selector
    [Serializable]
    public class TestOption : IBqlTable
    {
        [PXString(IsKey = true)]
        [PXUIField(DisplayName = "Option ID")]
        public virtual string OptionID { get; set; }
        public abstract class optionID : IBqlField { }

        [PXString]
        [PXUIField(DisplayName = "Description")]
        public virtual string Description { get; set; }
        public abstract class description : IBqlField { }
    }

    // The Custom Selector attribute
    public class CustomSelectorTestAttribute : PXCustomSelectorAttribute
    {
        public CustomSelectorTestAttribute()
            : base(typeof(TestOption.optionID)) { }

        public IEnumerable GetRecords()
        {
            // These records would come from an external source
            yield return new TestOption() { OptionID = "A", Description = "Alpha" };
            yield return new TestOption() { OptionID = "B", Description = "Bravo" };
            yield return new TestOption() { OptionID = "C", Description = "Charlie" };
            yield return new TestOption() { OptionID = "D", Description = "Delta" };
        }
    }

    // A maintenance screen graph
    public class TestMaint : PXGraph<TestMaint, TestDAC>
    {
        public PXSelect<TestDAC> Records;
    }
}

ASPX 页面:

<%@ Page Language="C#" MasterPageFile="~/MasterPages/ListView.master" AutoEventWireup="true" ValidateRequest="false" CodeFile="XX101000.aspx.cs" Inherits="Page_XX101000" Title="Untitled Page" %>
<%@ MasterType VirtualPath="~/MasterPages/ListView.master" %>

<asp:Content ID="cont1" ContentPlaceHolderID="phDS" runat="Server">
    <px:PXDataSource ID="ds" runat="server" Visible="True" Width="100%" PrimaryView="Records" TypeName="CustomSelectorTest.TestMaint"  />
</asp:Content>
<asp:Content ID="cont2" ContentPlaceHolderID="phL" runat="Server">
    <px:PXGrid ID="grid" runat="server" Height="400px" Width="100%" Style="z-index: 100"
        AllowPaging="True" AllowSearch="True" AdjustPageSize="Auto" DataSourceID="ds" SkinID="Primary" TabIndex="25000">
        <Levels>
            <px:PXGridLevel DataKeyNames="OptionID" DataMember="Records">
                <RowTemplate>
                    <px:PXSelector ID="edOptionID" runat="server" AutoRefresh="True" DataField="OptionID" CommitChanges="true" Size="SM" />
                    <px:PXTextEdit ID="edUserData" runat="server" AlreadyLocalized="False" DataField="UserData" DefaultLocale="" Size="SM" />
                </RowTemplate>
                <Columns>
                    <px:PXGridColumn DataField="OptionID" />
                    <px:PXGridColumn DataField="UserData" />
                </Columns>
            </px:PXGridLevel>
        </Levels>
        <AutoSize Container="Window" Enabled="True" MinHeight="200" />
    </px:PXGrid>
</asp:Content>

【问题讨论】:

    标签: acumatica


    【解决方案1】:

    将字段大小添加到字段的 [PXDBString] 属性更正了问题。

    [PXDBString(10, IsKey = true)]
    ...
    public virtual string OptionID { get; set; }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多