为什么我的 PXSelector 会忽略我选择的内容

Why does my PXSelector ignore what I have selected

我在 POLandedCostDocEntry 上创建了一个 PXGraphExtension。我添加了一个 PXAction 按钮。按下按钮时,我会显示一个弹出面板,要求用户提供到岸成本代码。

问题是 PXSelector 忽略了我在该字段中输入的任何内容并重置为 APPLE(或按字母顺序排在首位的任何到岸成本代码)。如果我使用 Selector 选择不同的代码,代码 I select 会显示片刻,然后立即再次替换为 APPLE。

弹出对话框的ASPX如下:

  <px:PXSmartPanel runat="server" ID="PanelAskForLCCode" LoadOnDemand="True" AutoRepaint="True" Key="LandedCostCodeSelection" CaptionVisible="True" Caption="Select Landed Cost Code" AcceptButtonID="CstButton4" CancelButtonID="CstButton5">
    <px:PXPanel runat="server" ID="CstPanel9">
      <px:PXFormView runat="server" ID="CstFormView10" SkinID="Transparent" Width="100%" SyncPosition="True" DataMember="LandedCostCodeSelection" DataSourceID="ds">
        <Template>
          <px:PXSelector runat="server" ID="CstPXSelector11" DataField="LandedCostCodeID" CommitChanges="True" DataSourceID="ds">
            </px:PXSelector>
        </Template>
      </px:PXFormView>
    </px:PXPanel>
    <px:PXPanel runat="server" ID="LandedCostCodeSelectionButtons" SkinID="Buttons">
      <px:PXButton runat="server" ID="CstButton4" DialogResult="OK" Text="OK" />
      <px:PXButton runat="server" ID="CstButton5" DialogResult="Cancel" Text="Cancel" />
    </px:PXPanel></px:PXSmartPanel>

我在对话框中引用的视图代码是:

public PXSelect<LandedCostCode> LandedCostCodeSelection;

我用来调用对话框的代码是:

   if (LandedCostCodeSelection.AskExt() == WebDialogResult.OK)
        {
          //rest of code here
        }

我错过了什么来允许用户select或输入不同的到岸成本代码?

编辑 1: 我已将我在对话框中引用的视图的代码更改为:

public PXFilter<LandedCostCode> LandedCostCodeSelection;

我的 aspx 现在看起来像这样:

<px:PXSmartPanel runat="server" ID="PanelAskForLCCode" Key="LandedCostCodeSelection" CaptionVisible="True" Caption="Select Landed Cost Code" AcceptButtonID="CstButton4" CancelButtonID="CstButton5" Width="300px" AutoRepaint="True" LoadOnDemand="True">
    <px:PXFormView runat="server" ID="CstFormView18" CaptionVisible="False" Caption="LC Code Selection" DataSourceID="ds" DataMember="LandedCostCodeSelection">
        <Template>
            <px:PXLayoutRule runat="server" ID="CstPXLayoutRule19" StartColumn="True" ControlSize="XM" LabelsWidth="S"/>
            <px:PXSelector runat="server" ID="CstPXSelector20" DataField="LandedCostCodeID" CommitChanges="True" DataSourceID="ds" DataMember="LandedCostCodeSelection"/>
        </Template>
        <CallbackCommands>
            <Search CommitChanges="True"/>
        </CallbackCommands>
    </px:PXFormView>
    <px:PXPanel runat="server" ID="LandedCostCodeSelectionButtons" SkinID="Buttons">
        <px:PXButton runat="server" ID="CstButton4" DialogResult="OK" Text="OK"/>
        <px:PXButton runat="server" ID="CstButton5" DialogResult="Cancel" Text="Cancel"/>
    </px:PXPanel>
</px:PXSmartPanel>

我调用对话框如下:

if (LandedCostCodeSelection.AskExt((graph, view) =>
{
  LandedCostCodeSelection.Cache.Clear();
},true) == WebDialogResult.OK)
{

} 

我注意到,当我单击 selector 按钮并从 selector 中选择一行时(短暂 returns 字段的值,然后被正确覆盖away) 当我再次点击 selector 按钮时,selector 已经记住了我上次 selected.

的记录

最后,如果我按如下方式调用对话框:

if (LandedCostCodeSelection.AskExt((graph, view) =>
{
  LandedCostCodeSelection.Cache.Clear();
  LandedCostCodeSelection.Current.LandedCostCodeID = "XYZ";
},true) == WebDialogResult.OK)
{

} 

然后该字段将填充 XYZ,如果我单击“确定”,我可以引用 XYZ 的值。 (但是如果我使用selector,那么这个值就被清除了,不能再访问了。)

问题出在 DataView 的定义和使用的 DAC 上。我已经重现了这个问题,这就是我为让它起作用所做的改变:

使用新的自定义 DAC 作为您的视图源。请注意,该字段未绑定且不是键(没有 IsKey = true,如 LandedCostCode.LandedCostCodeID:

    [Serializable]
    [PXHidden]
    public partial class LandedCostCodeFilter: IBqlTable
    {
      #region LandedCostCodeID
      public abstract class landedCostCodeID : PX.Data.BQL.BqlString.Field<landedCostCodeID> { }
      [PXString(15, IsUnicode = true)]
      //[PXUnboudDefault("APPLE")] //optional, to preselect a value
      [PXUIField(DisplayName = "Landed Cost Code",Visibility=PXUIVisibility.SelectorVisible)]
      [PXSelector(typeof(Search<LandedCostCode.landedCostCodeID>))]
      public virtual String LandedCostCodeID {get; set}
      #endregion
    } 

更改 DataView 定义,使用 PXFilter 而不是 PXSelect 并使用新的 DAC

public PXFilter<LandedCostCodeFilter> LandedCostCodeSelection; 

更正该问题,您的对话框应该可以正常工作。

观察。 如果您想在打开对话框时预先选择一个值,请将 [PXUnboudDefault("APPLE")] 添加到 DAC

中的字段

不确定您的按钮定义是什么样的,但它应该是这样的:

  public PXAction<POLandedCostDoc> SelectLandedCost;
  [PXButton]
  [PXUIField(DisplayName = "Select Landed Cost Code", MapEnableRights = PXCacheRights.Delete, MapViewRights = PXCacheRights.Delete)]
  protected void selectLandedCost()
  {
     if(LandedCostCodeSelection.AskExt(true) != WebDialogResult.OK) return;
    
     // do some stuff here
  }

另外,我的aspx代码:

<px:PXSmartPanel runat="server" ID="PanelAskForLCCode" Caption="Select Landed Cost Code" CaptionVisible="True" Key="LandedCostCodeSelection">
<px:PXFormView runat="server" ID="CstFormView2" DataMember="LandedCostCodeSelection" SkinID="Transparent" DataSourceID="ds" Height="100%" Width="100%">
  <Template>
    <px:PXLayoutRule runat="server" ID="CstPXLayoutRule3" StartColumn="True" />
    <px:PXSelector runat="server" ID="CstPXSelector4" DataField="LandedCostCodeID" CommitChanges="True" AutoRefresh="True" />
    <px:PXPanel runat="server" ID="LandedCostCodeSelectionButtons" SkinID="Buttons">
      <px:PXButton runat="server" ID="CstButton6" DialogResult="OK" Text="OK" />
      <px:PXButton runat="server" ID="CstButton7" DialogResult="Cancel" Text="Cancel" /></px:PXPanel></Template></px:PXFormView></px:PXSmartPanel>