InitRow = true 删除所有记录

InitRow = true deleting all records

我运行在我正在处理的扩展中遇到了一个有趣的情况。

该扩展存在于“客户位置”屏幕上,并且有一个额外的网格。

此网格的 DAC 有四个主键

公司编号, 账户ID, 地点编号, 排序顺序

DAC中的主键定义如下

    #region BAccountID

    public abstract class bAccountID : PX.Data.IBqlField
    {
    }

    protected int? _BAccountID;

    [PXDBInt(IsKey = true)]
    [PXDefault(typeof(Location.bAccountID))]
    public virtual int? BAccountID
    {
        get
        {
            return this._BAccountID;
        }
        set
        {
            this._BAccountID = value;
        }
    }

    #endregion BAccountID

    #region LocationID

    public abstract class locationID : PX.Data.IBqlField
    {
    }

    protected int? _LocationID;

    [PXDBInt(IsKey = true)]
    [PXDefault(typeof(Location.locationID))]
    public virtual int? LocationID
    {
        get
        {
            return this._LocationID;
        }
        set
        {
            this._LocationID = value;
        }
    }

    #endregion LocationID

    #region SortOrder

    public abstract class sortOrder : PX.Data.IBqlField
    {
    }

    protected int? _SortOrder;

    [PXDBInt(IsKey = true)]
    [PXDefault]
    [PXLineNbr(typeof(CWACustomerLocationItem))]
    [PXParent(typeof(Select<CWACustomerLocationItem,
        Where<CWACustomerLocationItem.bAccountID, Equal<Current<Location.bAccountID>>, And<CWACustomerLocationItem.locationID, Equal<Current<Location.locationID>>>>>))]
    [PXUIField(DisplayName = "Sort Order", Enabled = false)]
    public virtual int? SortOrder
    {
        get
        {
            return this._SortOrder;
        }
        set
        {
            this._SortOrder = value;
        }
    }

    #endregion SortOrder

我 运行 遇到的问题是,如果在网格定义中,我设置 "InitRow = false",排序顺序中的第一个数字从 2 而不是 1 开始,并且不相加本身直到该行完成。

如果我在添加新行时设置 "InitRow = true",则排序顺序正确地从 1 开始并正确递增,但是如果我添加新行并且不更新其他值(仅显示排序顺序),则在保存时网格中的所有行都被删除了。

我已验证数据库中的所有 "non-null" 字段都在 DAC 中指定

全格定义如下

<px:PXGrid runat="server" ID="CstPXGrid1" Width="100%" SkinID="DetailsInTab" KeepPosition="True" SyncPosition="True">
        <Levels>
          <px:PXGridLevel DataMember="LocationItem">
            <Columns>
              <px:PXGridColumn DataField="SortOrder" Width="70" />
              <px:PXGridColumn DataField="InventoryID" Width="120" AutoCallBack="True" />
              <px:PXGridColumn DataField="InventoryID_description" Width="200" />
              <px:PXGridColumn DataField="SellingUOM" Width="70" />
              <px:PXGridColumn DataField="SellingPrice" Width="100" />
              <px:PXGridColumn DataField="MinQty" Width="100" />
              <px:PXGridColumn DataField="MaxQty" Width="100" />
              <px:PXGridColumn DataField="EOQ" Width="100" />
              <px:PXGridColumn DataField="Comments" Width="70" />
              <px:PXGridColumn DataField="Inactive" Width="60" Type="CheckBox" /></Columns></px:PXGridLevel></Levels>
        <AutoSize Enabled="True" Container="Parent" MinHeight="200" />
        <ActionBar>
          <CustomItems>
            <px:PXToolBarButton Text="Up" Tooltip="Move Node Up" CommandName="Up" Visible="True" CommandSourceID="ds">
              <Images Normal="main@ArrowUp" /></px:PXToolBarButton>
            <px:PXToolBarButton Text="Down" Tooltip="Move Node Down" CommandSourceID="ds" CommandName="Down">
              <Images Normal="main@ArrowDown" /></px:PXToolBarButton></CustomItems></ActionBar>
        <AutoCallBack Enabled="True" />
        <Mode InitNewRow="True" /></px:PXGrid>

我已经用过 "InitRow" 好几次了,但还没有 运行 进入这个,所以我不确定到底是哪里出了问题。

最让我困扰的是它会在保存时删除所有行。

有人对寻找什么有任何理论或建议吗?

我相信我找到了问题所在。上面PXParent/number的定义是错误的。

正确的排序 DAC 如下:

    [PXDBInt(IsKey = true)]
    [PXDefault()]
    [PXLineNbr(typeof(Location),false)]
    [PXParent(typeof(Select<Location,
        Where<Location.bAccountID, Equal<Current<CWACustomerLocationItem.bAccountID>>, And<Location.locationID, Equal<Current<CWACustomerLocationItem.locationID>>>>>))]
    [PXUIField(DisplayName = "Sort Order", Enabled = false)]