Acumatica智能面板打开时不显示空数据消息问题
I get it—having to click refresh just to see the "no records" message isn't ideal for user experience. Let's fix that. Here's what's going on and how to resolve it:
The Problem
Your Smart Panel's PXGrid loads fine when there's data, but when the TestSteps view has no records, the empty message only appears after manually clicking the grid's refresh button. This happens because the grid isn't properly triggering a data check when the panel first opens, even with AutoReload enabled.
Your Current Code
First, let's recap your existing setup for context:
ASPX Markup
<asp:Content ID="cont1" ContentPlaceHolderID="phDS" runat="Server"> <px:PXDataSource ID="ds" runat="server" Visible="True" TypeName="GraphName" PrimaryView="MyOrders" PageLoadBehavior="GoLastRecord" AttributesFound="False" EnableAttributes="False" SuspendUnloading="False"> <CallbackCommands> <px:PXDSCallbackCommand Name="GotoSteps" Visible="False" DependOnGrid="PXGrid2" /> </CallbackCommands> </px:PXDataSource> </asp:Content> <px:PXTab ID="tab" runat="server" Width="100%" Height="100%"> <Items> <px:PXTabItem Text="Test Results"> <Template> <px:PXGrid ID="PXGrid2" runat="server" OnRowDataBound="grid2_RowDataBound" DataSourceID="ds" Width="100%" Height="100%" SkinID="DetailsInTab" SyncPosition="True" TabIndex="2600"> <EmptyMsg ComboAddMessage="No records found. Try to change filter or modify parameters above to see records here." NamedComboMessage="No records found as '{0}'. Try to change filter or modify parameters above to see records here." NamedComboAddMessage="No records found as '{0}'. Try to change filter or modify parameters above to see records here." FilteredMessage="No records found. Try to change filter to see records here." FilteredAddMessage="No records found. Try to change filter to see records here." NamedFilteredMessage="No records found as '{0}'. Try to change filter to see records here." NamedFilteredAddMessage="No records found as '{0}'. Try to change filter to see records here." AnonFilteredMessage="No records found. Try to change filter to see records here." AnonFilteredAddMessage="No records found. Try to change filter to see records here."></EmptyMsg> <Levels> <px:PXGridLevel DataKeyNames="OrderId" DataMember="MyOrders"> <Columns> <px:PXGridColumn DataField="Steps" Width="180px" LinkCommand="GotoSteps" CommitChanges="true"> </px:PXGridColumn> </Columns> </px:PXGridLevel> </Levels> <AutoSize Enabled="True" /> <AutoCallBack /> <ActionBar> <CustomItems> <px:PXToolBarButton Text="Add Sample" Key="cmdSample" CommandName="AddSample" CommandSourceID="ds" DependOnGrid="PXGrid2"> <AutoCallBack> <Behavior CommitChanges="True" PostData="Page"></Behavior> </AutoCallBack> </px:PXToolBarButton> </CustomItems> </ActionBar> </px:PXGrid> </Template> <AutoCallBack Target="PXGrid2" Command="Refresh"> <Behavior RepaintControlsIDs="PXGrid2" /> </AutoCallBack> </px:PXTabItem> </Items> <AutoSize Enabled="True" ></AutoSize> </px:PXTab> <asp:Content ID="cont2" ContentPlaceHolderID="phF" runat="Server"> <px:PXSmartPanel ID="pnlTestSteps" runat="server" Height="400px" Width="1100px" Caption="Test Steps" CaptionVisible="true" AutoReload="true" LoadOnDemand="true" Key="TestSteps" Style="position: static" AutoCallBack-Target="StepsGrid" AutoCallBack-Command="Refresh" DesignView="Content"> <px:PXGrid ID="StepsGrid" runat="server" DataSourceID="ds" SkinID="Inquire" Height="90%" Width="100%" AutoAdjustColumns="true" > <EmptyMsg ComboAddMessage="No records found. Try to change filter or modify parameters above to see records here." NamedComboMessage="No records found as '{0}'. Try to change filter or modify parameters above to see records here." NamedComboAddMessage="No records found as '{0}'. Try to change filter or modify parameters above to see records here." FilteredMessage="No records found. Try to change filter to see records here." FilteredAddMessage="No records found. Try to change filter to see records here." NamedFilteredMessage="No records found as '{0}'. Try to change filter to see records here." NamedFilteredAddMessage="No records found as '{0}'. Try to change filter to see records here." AnonFilteredMessage="No records found. Try to change filter to see records here." AnonFilteredAddMessage="No records found. Try to change filter to see records here."></EmptyMsg> <Levels> <px:PXGridLevel DataMember="TestSteps" Visible="true"> <Columns> <px:PXGridColumn DataField="Name"> </px:PXGridColumn> <px:PXGridColumn DataField="Description"> </px:PXGridColumn> </Columns> </px:PXGridLevel> </Levels> </px:PXGrid> <px:PXPanel ID="PXPanel7" runat="server" SkinID="Buttons"> <px:PXButton ID="PXButton9" runat="server" DialogResult="OK" Text="OK"></px:PXButton> </px:PXPanel> </px:PXSmartPanel> </asp:Content>
C# Graph Code
public PXAction<GraphClass> GoToSteps; [PXButton(Tooltip = "Open Popup" )] [PXUIField(DisplayName = "Steps")] public virtual void gotoSteps() { TestSteps.AskExt(true); return; }
Fixes to Implement
1. Refresh the TestSteps View Before Opening the Panel
The key issue is that when you call AskExt(true), the TestSteps view might not have been refreshed to confirm it's empty. Add a view refresh before opening the panel:
public PXAction<GraphClass> GoToSteps; [PXButton(Tooltip = "Open Popup" )] [PXUIField(DisplayName = "Steps")] public virtual void gotoSteps() { // Force the view to refresh so it knows it's empty (if no records exist) TestSteps.View.RequestRefresh(); // Now open the panel TestSteps.AskExt(true); return; }
2. Enhance the Smart Panel's AutoCallBack Configuration
Your current AutoCallBack settings are partial—add explicit behavior to ensure the grid repaints properly when the panel loads:
Update the Smart Panel markup to include a full AutoCallBack block (replace the inline AutoCallBack-Target and AutoCallBack-Command attributes):
<px:PXSmartPanel ID="pnlTestSteps" runat="server" Height="400px" Width="1100px" Caption="Test Steps" CaptionVisible="true" AutoReload="true" LoadOnDemand="true" Key="TestSteps" Style="position: static" DesignView="Content"> <AutoCallBack Target="StepsGrid" Command="Refresh"> <Behavior CommitChanges="True" PostData="Page" RepaintControlsIDs="StepsGrid" /> </AutoCallBack> <!-- Rest of your Smart Panel content remains the same --> </px:PXSmartPanel>
3. Double-Check View Binding
Make sure your TestSteps view in the graph is correctly defined as a select view pointing to the right DAC, and that the grid's DataMember="TestSteps" matches exactly.
Why These Fixes Work
TestSteps.View.RequestRefresh()ensures the view fetches the latest state (including empty) immediately before the panel opens, so the grid has accurate data to work with.- The enhanced
AutoCallBacktells the grid to explicitly refresh and repaint when the panel loads, which triggers the empty message rendering if there are no records.
These changes should make the empty message appear automatically as soon as the Smart Panel opens, no manual refresh required.
内容的提问来源于stack exchange,提问作者Nitin Jain

