First of all I want to say that if you do not use "PXTabItem" in your "PXSmartPanel" you should not set LoadOnDemand(by default this attribute has "False" value).
In our example I will show you the difference between using this attribute for "PXSmartPanel" with "True" or "False" values. For that I prepared a short example:
We will use two TabItems (Stock Items for the first and Non-Stock Items for the second).
Let's create them in GraphExt.
public SelectFrom<InventoryItem>.Where<InventoryItem.stkItem.IsEqual<True>>.View StockItemView;
public SelectFrom<InventoryItem>.Where<InventoryItem.stkItem.IsEqual<False>>.View NonStockItemView;
Let's add button to GraphExt and to the View. For this example we will use the Sales Orders page and add PXSmartPanel to the View.
public sealed class SoOrderEntryExt : PXGraphExtension<SOOrderEntry>
{
public static bool IsActive() => true;
public PXSelect<SOLine> MyPanelView;
public PXAction<SOOrder> noteAction;
[PXUIField(DisplayName = "TestNoteButton", MapViewRights = PXCacheRights.Select, MapEnableRights = PXCacheRights.Update)]
[PXButton(ImageKey = PX.Web.UI.Sprite.Main.DataEntryF)]
protected IEnumerable NoteAction(PXAdapter adapter)
{
if (Base.Transactions.Current != null &&
MyPanelView.AskExt() == WebDialogResult.OK)
{
//extra stuff here if needed when OK is pushed
}
return adapter.Get();
}
public SelectFrom<InventoryItem>.Where<InventoryItem.stkItem.IsEqual<True>>.View StockItemView;
public SelectFrom<InventoryItem>.Where<InventoryItem.stkItem.IsEqual<False>>.View NonStockItemView;
}
ASPX. PXSmartPanel:
<px:PXSmartPanel runat="server" ID="PXSmartPanelNote" DesignView="Hidden" LoadOnDemand="false" CreateOnDemand="false"
CaptionVisible="true" Caption="Order Notes" Key="MyPanelView">
<px:PXTab ID="PXTab123" runat="server" Height="540px" Style="z-index: 100;" Width="100%">
<Items>
<px:PXTabItem Text="NonStockItem" >
<Template>
<px:PXGrid runat="server" ID="CstPXGrid4" Width="100%" DataSourceID="ds" SyncPosition="True">
<Levels>
<px:PXGridLevel DataMember="NonStockItemView">
<Columns>
<px:PXGridColumn DataField="StkItem" Width="60" />
<px:PXGridColumn DataField="InventoryCD" Width="70" />
</Columns>
</px:PXGridLevel>
</Levels>
</px:PXGrid>
</Template>
</px:PXTabItem>
<px:PXTabItem Text="StockItem">
<Template>
<px:PXGrid runat="server" ID="CstPXGrid5" Width="100%" SyncPosition="True" DataSourceID="ds">
<Levels>
<px:PXGridLevel DataMember="StockItemView">
<Columns>
<px:PXGridColumn DataField="StkItem" Width="60" />
<px:PXGridColumn DataField="InventoryCD" Width="70" />
</Columns>
</px:PXGridLevel>
</Levels>
</px:PXGrid>
</Template>
</px:PXTabItem>
</Items>
</px:PXTab>
<px:PXPanel runat="server" ID="PXPanel12" SkinID="Buttons">
<px:PXButton runat="server" ID="btnMyNoteOk" Text="OK" DialogResult="OK" />
</px:PXPanel>
</px:PXSmartPanel>
ASPX. Callback:
<CallbackCommands>
<px:PXDSCallbackCommand CommitChanges="true" Name="NoteAction" Visible="False" DependOnGrid="grid" />
</CallbackCommands>
ASPX. Action Bar:
<px:PXToolBarButton Text="TestNoteButton" DependOnGrid="grid">
<AutoCallBack Command="NoteAction" Target="ds" />
</px:PXToolBarButton>