-->

Smartpanel text do not refresh

2019-06-14 14:12发布

问题:

I am displaying few textboxes on my custom smartpanel. The text to display is obtained by clicking each row in the grid and showed on smartpanel.

However, the issue is whenever I click on first time any row, it displays correctly all text correctly but next time onwards it still shows the previous one and do not get refreshed.

Here is the code I am using-

public PXSelect<CRAcumaticaActivity,
        Where<CRAcumaticaActivity.activityID, Equal<Current<CRAcumaticaActivity.activityID>>>> CurrentAcuViewActivity;

public PXAction<CRCase> acuViewActivity;

    [PXButton(ImageKey = PX.Web.UI.Sprite.Main.ArrowUp, CommitChanges = false)]
    [PXUIField(DisplayName = "View Activity", MapEnableRights = PXCacheRights.Select, MapViewRights = PXCacheRights.Select)]
    protected virtual IEnumerable AcuViewActivity(PXAdapter adapter)
    {
        CurrentAcuViewActivity.AskExt();

        return adapter.Get();
    }

Here is the smartpanel aspx code-

<px:PXSmartPanel ID="pnlAcuViewActivity" runat="server" Style="z-index: 108;"
    Caption="Acumatica Activity" CaptionVisible="True" LoadOnDemand="true"
    ShowAfterLoad="true" AutoCallBack-Command="Refresh"  Key="CurrentAcuViewActivity"
    AutoCallBack-Target="frmAcuViewActivity" DesignView="Content"
    AcceptButtonID="PXButtonOK" CancelButtonID="PXButtonOK">
    <px:PXFormView ID="frmAcuViewActivity" runat="server" DataSourceID="ds"  DataMember="CurrentAcuViewActivity"
        Style="z-index: 100"
        Caption="Acumatica Activity" CaptionVisible="False"
        SkinID="Transparent" TabIndex="17100">
        <Template>
            <px:PXLayoutRule runat="server" StartRow="True">
            </px:PXLayoutRule>
            <px:PXTextEdit ID="edSummary" runat="server" DataField="Summary" Enabled="false">
            </px:PXTextEdit>
            <px:PXRichTextEdit ID="edDescription" runat="server" DataField="Description" Height="200px" Width="500px">
            </px:PXRichTextEdit>
        </Template>
    </px:PXFormView>
    <px:PXPanel ID="PXPanel1" runat="server" SkinID="Buttons">
        <px:PXButton ID="pxBtnOK" runat="server" DialogResult="OK" Text="Close" />
    </px:PXPanel>
</px:PXSmartPanel>

Is there anything I am missing. Please suggest.

回答1:

For your smartpanel, why do you have: ShowAfterLoad, AutoCallBack-*, and AcceptButtonID/CancelButtonID set to same button?

ShowAfterLoad property controls the display during loading of the panel. AutoCallBack properties apply to any callback generated by controls on the panel

I suggest to have your smartpanel declared as follows: Note, AutoRepaint property which forces the panel to repaint itself everytime it opens.

<px:PXSmartPanel ID="pnlAcuViewActivity" runat="server" Style="z-index: 108;"
Caption="Acumatica Activity" CaptionVisible="True" LoadOnDemand="true"
 Key="CurrentAcuViewActivity"
AcceptButtonID="PXButtonOK" 
AutoRepaint="true">

The other thing I can think of is you should ensure not to use the same data view in more than one container.



回答2:

Did you set the grid's SyncPosition = true?

The SyncPosition property of a grid enables setting the Current property of the cache object to each row selected by the user in the grid. This property is required for syncing the lookup lists with the currently selected row in the grid, if the data displayed in the lookup depends on the selected row.

If still not working just try clearing the cache of the related view for every select using a delegate.

NOT TESTED

public PXSelect<CRAcumaticaActivity,
        Where<CRAcumaticaActivity.activityID, Equal<Current<CRAcumaticaActivity.activityID>>>> CurrentAcuViewActivity;
 protected virtual IEnumerable currentAcuViewActivity()
{
  CurrentAcuViewActivity.Cache.Clear();
  return CurrentAcuViewActivity.Select();
}


回答3:

To refresh data in a SmartPanel you should use AskExt(PXView.InitializePanel initializeHandler, bool refreshRequired); the code will look like this:

          if (CurrentAcuViewActivity.AskExt(
            (graph, view) =>
            {
                CurrentAcuViewActivity.Cache.ClearQueryCache();
                CurrentAcuViewActivity.View.Clear();
                CurrentAcuViewActivityCache.Clear();
            }
            , true) != WebDialogResult.OK)
          return adapter.Get();


标签: acumatica