在新页面中使用CSAttributes

时间:2018-05-09 19:52:05

标签: acumatica

我们有一个新页面,我们希望使用CS属性,类似于它们在Item Class和Non Stock项目页面中的使用方式

  • 项目类别:属性定义。
  • 非库存商品页面:属性实施。

Attribute definition in the Item Class page

Attribute use in the NonStockitem page 注意:我简化了页面以缩小ASPX中任何可能需要的属性。

基于此,我的属性定义页面包含以下元素:

图表:

#region Datamembers
public PXSelect<MDEquipmentType> EquipmentType;

[PXViewName("Attributes")]
public CSAttributeGroupList<MDEquipmentType, MDEquipment> Mapping;
#endregion

ASPX:

<px:PXTabItem Text="Attributes">
            <Template>
                <px:PXGrid ID="grid" runat="server" DataSourceID="ds" Height="150px" Style="z-index: 100;
                    border: 0px;" Width="100%" ActionsPosition="Top" SkinID="Details"  MatrixMode="True">
                    <Levels>
                        <px:PXGridLevel DataMember="Mapping">
                            <RowTemplate>
                                <px:PXSelector CommitChanges="True" ID="edAttributeID" runat="server" DataField="AttributeID" AllowEdit="True" FilterByAllFields="True" />
                            </RowTemplate>
                            <Columns>
                                <px:PXGridColumn DataField="IsActive" AllowNull="False" TextAlign="Center" Type="CheckBox" />
                                <px:PXGridColumn DataField="AttributeID" Width="81px" AutoCallBack="true" LinkCommand="CRAttribute_ViewDetails" />
                                <px:PXGridColumn AllowNull="False" DataField="Description" Width="351px" />
                                <px:PXGridColumn DataField="SortOrder" TextAlign="Right" Width="81px" SortDirection="Ascending" />
                                <px:PXGridColumn AllowNull="False" DataField="Required" TextAlign="Center" Type="CheckBox" />
                                <px:PXGridColumn AllowNull="True" DataField="CSAttribute__IsInternal" TextAlign="Center" Type="CheckBox" />
                                <px:PXGridColumn AllowNull="False" DataField="ControlType" Type="DropDownList" Width="81px" />
                                <px:PXGridColumn AllowNull="True" DataField="DefaultValue" Width="100px" RenderEditorText="False" />
                            </Columns>
                        </px:PXGridLevel>
                    </Levels>
                    <AutoSize Enabled="True" MinHeight="150" />
                </px:PXGrid>
            </Template>
        </px:PXTabItem> 

结果: Our page result

到目前为止,所有记录都在表CSAttributeGroup

中正确保存在DB中

现在,当我尝试在数据输入页面中应用属性时出现问题。

这是页面: Attribute not shown

设置设备类型时,不会填充属性网格。

图表定义:

  public class MDEquipmentEntry : PXGraph<MDEquipmentEntry, MDEquipment>
    {
        #region Datamembers
        public PXSelect<MDEquipment> Equipment;

        public CRAttributeList<MDEquipment> Answers;

ASPX:

   <px:PXTabItem Text="Attributes">
        <Template>
            <px:PXGrid ID="PXGridAnswers" runat="server" Caption="Attributes" DataSourceID="ds" SkinID="Inquire" Width="100%" Height="200px" MatrixMode="True">
                <Levels>
                    <px:PXGridLevel DataMember="Answers">
                        <Columns>
                            <px:PXGridColumn DataField="AttributeID" />
                            <px:PXGridColumn DataField="isRequired" TextAlign="Center" Type="CheckBox" Width="80px"/>
                            <px:PXGridColumn DataField="Value" Width="300px" AllowShowHide="False" AllowSort="False" />
                        </Columns>
                        <Layout FormViewHeight="" />
                    </px:PXGridLevel>
                </Levels>
                <AutoSize Enabled="True" MinHeight="200" />
                <ActionBar>
                    <Actions>
                        <Search Enabled="False" />
                    </Actions>
                </ActionBar>
                <Mode AllowAddNew="False" AllowColMoving="False" AllowDelete="False" />
            </px:PXGrid>
        </Template>
    </px:PXTabItem> 

在Nonstock项目页面中,在插入Item Class后立即加载该属性。所以我确保commitChanges属性已添加到我的页面。还查找了可能触发插入的FieldUpdated事件,但似乎并不需要。

我的代码中可能缺少什么?

1 个答案:

答案 0 :(得分:1)

CRAttributeList的实现取决于在类中某处定义的类ID字段。初始化后,CRAttributeList将在MDEquipment DAC中查找使用CRAttributesField属性修饰的字段。

对于InventoryItem DAC,以下是它的定义方式:

    [CRAttributesField(typeof(InventoryItem.itemClassID))]
    public virtual string[] Attributes { get; set; }

如果系统无法确定当前的类ID,则不会使用任何内容填充属性网格。