0
votes

I'm running into an interesting situation on an extension I'm working on.

The extension exists on the Customer Location screen and has an additional grid.

The DAC for this grid has four primary keys

CompanyID, BAccountID, LocationId, SortOrder

Primary keys in the DAC are defined as follows

    #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

The issue I'm running into is if on the grid definition, I set "InitRow = false", the first number in the sort order starts at 2 instead of 1 and doesn't add itself until the row is complete.

If I set "InitRow = true" when adding a new row, the sortorder propertly starts at 1 and increments correctly, however if I add a new row and update no other values (only sortorder is shown), when saving all rows in the grid are deleted out.

I've validated that all "non-null" fields in the database are specified as such in the DAC

Full Grid is defined as below

<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>

I've used "InitRow" several other times and haven't run into this so I'm not sure exactly where the fault is coming into play.

The fact that it removes all rows on save is what bothers me the most.

Anyone have any theories or advice on what to look for?

1
When looking into this a bit more, when it deletes the records, it's deleting all records in the table. not just for the current customer - Jeff Williams

1 Answers

2
votes

I believe I figured out the problem. The definition of PXParent/number is wrong in the above.

The correct sortorder DAC is below:

    [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)]