I have a custom selector inheriting from PXCustomSelectorAttribute. Whenever I use it in a grid column the field appears blank until clicking into the field as if to change it. Then the existing saved value appears as normal in an editor. Navigating away from the grid cell the value again disappears.
I've prepared a very simplified test that produces this behavior and confirmed the "AutoRefresh" property is set to true as described in a similar post.
As shown in the image above, the data records use the custom selector for their "Option ID" and all three records have values in the DB & DAC. The Selector does show the options returned from the GetRecords() method. But the field values don't show in the grid until clicking into the field.
Example code:
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:
<%@ 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>
