在 Dynamics 365 CRM 统一接口的子网格 reload/refresh 上重新加载表单
Reload Form on reload/refresh of subgrid in Dynamics 365 CRM Unified Interface
我有一个场景,在 Orders Form 中有一个 Invoice Schedule 子网格 。当 发票计划子网格 在 [=15= 重新加载时,我需要 Refresh/Reload 主表格 ]停用子网格中的特定记录。
P.S: 此方案适用于 Dynamics 365 CRM 统一接口 (UCI)。我已经尝试了所有三个子网格事件,但在这种情况下没有帮助。
您必须附加自定义事件处理程序才能处理此问题。 Read more
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();
我有一个场景,在 Orders Form 中有一个 Invoice Schedule 子网格 。当 发票计划子网格 在 [=15= 重新加载时,我需要 Refresh/Reload 主表格 ]停用子网格中的特定记录。
P.S: 此方案适用于 Dynamics 365 CRM 统一接口 (UCI)。我已经尝试了所有三个子网格事件,但在这种情况下没有帮助。
您必须附加自定义事件处理程序才能处理此问题。 Read more
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();