如何在Acumatica中创建主细节网格?

如何在Acumatica中创建主细节网格?,acumatica,acumatica-kb,Acumatica,Acumatica Kb,我正在处理一个自定义页面,通过按层次顺序显示表数据来可视化父记录和子记录之间的关系 我的BLC中有两个数据视图,我想将其用作两个PXGrids的数据源,以主/详细格式显示数据。在主网格中选择记录时,所有相关的子条目都应显示在详细信息网格中 我应该如何在Aspx中声明我的2PXGrids以完成此任务?例如,如果某些BLC包含类别数据视图和相关产品数据视图,您可以将类别视图指定为主网格的数据源,将产品视图指定为详细网格的数据源。当在主网格中选择类别时,与该类别关联的所有产品都将显示在“产品数据”视图

我正在处理一个自定义页面,通过按层次顺序显示表数据来可视化父记录和子记录之间的关系

我的BLC中有两个数据视图,我想将其用作两个PXGrids的数据源,以主/详细格式显示数据。在主网格中选择记录时,所有相关的子条目都应显示在详细信息网格中


我应该如何在Aspx中声明我的2PXGrids以完成此任务?

例如,如果某些BLC包含类别数据视图和相关产品数据视图,您可以将类别视图指定为主网格的数据源,将产品视图指定为详细网格的数据源。当在主网格中选择类别时,与该类别关联的所有产品都将显示在“产品数据”视图的详细信息网格中

public class ProductCategories : PXGraph<ProductCategories>
{
    #region Actions
    public PXSave<Category> Save;
    public PXCancel<Category> Cancel;
    #endregion

    #region Data Members
    public PXSelect<Category> Categories;

    public PXSelect<CategoryProduct,
        Where<CategoryProduct.categoryID, 
            Equal<Current<Category.categoryID>>>> CategoryProducts;
    #endregion

    #region Event Handlers
    protected virtual void Category_RowSelected(PXCache sender, PXRowSelectedEventArgs e)
    {
        this.CategoryProducts.Cache.AllowInsert = e.Row != null;
    }
    #endregion
}
公共类产品类别:PXGraph
{
#区域行动
公共储蓄;
公共服务取消;
#端区
#区域数据成员
公共部门选择类别;
公共PX选择类别产品;
#端区
#区域事件处理程序
已选择受保护的虚拟无效类别(PXCache发送方,PXRowSelectedEventArgs e)
{
this.CategoryProducts.Cache.AllowInsert=e.行!=null;
}
#端区
}
如上面的代码片段所示,详图视图通过CurrentBQL操作符与主视图一起引用。另外,请注意,如果主网格中没有一条记录,则为类别定义的事件处理程序将禁用详细信息网格上的插入按钮

下一步是在Aspx中配置主细节PXGrids

  • 对于主网格,将SyncPosition属性设置为true,然后定义AutoCallBackOnChangeCommand属性,如下所示,以便每次在主网格中选择不同的记录或根本没有记录时相应地刷新详细网格:

    <px:PXGrid ID="masterGrid" runat="server" DataSourceID="ds" SkinID="Details"
        SyncPosition="True" Caption="Categories" CaptionVisible="True" Width="100%">
        <AutoCallBack Command="Refresh" Target="detailGrid" />
        <OnChangeCommand Command="Refresh" Target="detailGrid" />
        ...
    </px:PXGrid>
    
    <px:PXGrid ID="detailGrid" runat="server" DataSourceID="ds" SkinID="Details"
        Caption="Products" CaptionVisible="True" Width="100%">
        <CallbackCommands>
            <Refresh SelectControlsIDs="masterGrid" />
        </CallbackCommands>
        ...
    </px:PXGrid>
    
    
    

    <px:PXSplitContainer runat="server" ID="sp" PositionInPercent="true" SplitterPosition="50"
        SkinID="Horizontal" Orientation="Horizontal" Panel1MinSize="250" Panel2MinSize="250">
        <AutoSize Enabled="true" Container="Window" />
        <Template1>
            <px:PXGrid ID="masterGrid" runat="server" DataSourceID="ds" SkinID="Details"
                SyncPosition="True" Caption="Categories" CaptionVisible="True" Width="100%">
                <AutoCallBack Command="Refresh" Target="detailGrid" />
                <OnChangeCommand Command="Refresh" Target="detailGrid" />
                <Levels>
                    <px:PXGridLevel DataMember="Categories">
                        <Columns>
                            ...
                        </Columns>
                    </px:PXGridLevel>
                </Levels>
                <AutoSize Enabled="True" />
            </px:PXGrid>
        </Template1>
        <Template2>
            <px:PXGrid ID="detailGrid" runat="server" DataSourceID="ds" SkinID="Details"
                Caption="Products" CaptionVisible="True" Width="100%">
                <CallbackCommands>
                    <Refresh SelectControlsIDs="masterGrid" />
                </CallbackCommands>
                <Levels>
                    <px:PXGridLevel DataMember="CategoryProducts">
                        <Columns>
                            ...
                        </Columns>
                    </px:PXGridLevel>
                </Levels>
                <AutoSize Enabled="True" />
            </px:PXGrid>
        </Template2>
    </px:PXSplitContainer>