簡體   English   中英

在 Dynamics 365 CRM 統一界面中重新加載/刷新子網格時重新加載表單

[英]Reload Form on reload/refresh of subgrid in Dynamics 365 CRM Unified Interface

我有一個場景,在Orders Form 中有一個Invoice Schedule Sub-grid 當在取消激活子網格中的特定記錄時重新加載發票計划子網格時,我需要刷新/重新加載主表單

PS:此方案適用於 Dynamics 365 CRM 統一接口 (UCI)。 我已經嘗試了所有三個子網格事件,但在這種情況下沒有幫助。

您必須附加一個自定義事件處理程序來處理此問題。 閱讀更多

var globalFormContext;

function myFormOnload(executionContext) {
  globalFormContext = executionContext.getFormContext(); 

  addSubgridEventListener();
} 

function addSubgridEventListener(){
  var gridContext = globalFormContext.getControl("<your_subgrid_name>");
  //ensure that the subgrid is ready…if not wait and call this function again
  if (gridContext == null){
     setTimeout(function () { addSubgridEventListener(); }, 500);
     return;
  }
  //bind the event listener when the subgrid is ready
  gridContext.addOnLoad(subgridEventListener);

}

function subgridEventListener(context){
  globalFormContext.data.refresh(false);
}

此最新代碼已驗證並在 v9 統一界面中工作 參考: https : //docs.microsoft.com/en-us/powerapps/developer/model-driven-apps/clientapi/reference/grids/gridcontrol/addonload

代碼片段:

//On load of main form event
function OnloadOfMainForm(executionContext) {
// call onLoad of subgrid function
  SubgridEventHandler(executionContext);
} 

var globalFormContext;
function SubgridEventHandler(executionContext){
//make formContext as global
  globalFormContext = executionContext.getFormContext(); 
  var gridContext = globalFormContext.getControl("subgrid_name");

  //Verify the subgrid is loaded, if not recursively call function again
  if (gridContext != null && gridContext != undefined){
      //don't try to pass formEontext some time it doesn't works
      gridContext.addOnLoad(SubgridFunctionExe);
     }else{
        setTimeout(function () { SubgridEventHandler(); }, 200);
     }
}

//It triggers onLoad of form, on load and on refresh of subgrid
//as well on add new record and on delete of record it will trigger
function SubgridFunctionExe(){
// here use globalFormContext
  globalFormContext.data.refresh(false);
}

對於 UCI:從功能區按鈕傳遞 PrimaryControl 的參數並使用以下代碼刷新。

PrimaryControl.refresh();

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM