powerapps - 在模型驱动的 PowerApps 中使用过滤后的数据反应渲染新视图
问题描述
目前我正在模型驱动的应用程序中实现自定义列表。我注意到在过滤数据时调用了 init 方法以及该updateView
方法,此外该updateView
方法被调用了 3 次。但是,不会呈现新视图。
我的猜测是我的组件没有正确排序和处理异步承诺,因此init
最后的方法会将所有内容重置为原始数据或用原始数据覆盖它。
这样做的正确方法是什么?
- 最初渲染组件(我的意思是
init
orupdateView
方法中的渲染代码)? - 如果刷新数据,如何处理异步调用以再次呈现视图?
目前,代码如下所示:
public init(context: ComponentFramework.Context<IInputs>, notifyOutputChanged: () => void, state: ComponentFramework.Dictionary, container: HTMLDivElement) {
this._context = context;
//load the global context with the app properties.
this._globalContext = Xrm.Utility.getGlobalContext();
this._globalContext.getCurrentAppProperties().then((appProperties:any) =>{
this._currentAppProperties = appProperties;
this._projectList = React.createElement(ProjectDetailList,{context:this._context, appProperties: this._currentAppProperties, globalContext: this._globalContext});
ReactDOM.render(React.createElement(Fabric, null, this._projectList), container);
}, (error:any) =>{console.log(error)});
}
public updateView(context: ComponentFramework.Context<IInputs>): void {
// storing the latest context from the control.
this._context = context;
this._globalContext = Xrm.Utility.getGlobalContext();
this._globalContext.getCurrentAppProperties().then((appProperties:any) =>{
this._currentAppProperties = appProperties;
ReactDOM.render(React.createElement(Fabric, null, React.createElement(ProjectDetailList,{context:this._context, appProperties: this._currentAppProperties, globalContext: this._globalContext})), this._container);
}, (error:any) =>{console.log(error)});
console.log("NEW CONTEXT!!!! ->>>>>>>>>>>>>>>>>>>>>>>")
console.log(this._currentAppProperties);
console.log(context);
console.log(this._context);
}
解决方案
您需要调用notifyOutputChanged
which 将反过来调用updateView
NotifyOutputChange 调用 CRM 客户端层来更新值,它使表单变脏(退出前保存)。此外,所有业务层逻辑(如 clientAPI、PBL 和字段验证)都被启动。如果不需要,并且控件只需要更改 UI,您可以跳过 notifyOutputChange。
控件重新加载、页面大小调整和外部业务逻辑更新控件值触发 UpdateView。
在 React 框架中 - 你应该像下面这样:
我们需要创建一个 notifyChange 函数,它会更新 PCF 的输出值,并在我们的 PCF 组件中调用 notifyOutputChanged。
我们可以将 notifyChange 函数作为 props 的一部分传递给我们的自定义 React 组件。每当在我们的 React 组件中更新值时,都会执行 notifyChange 函数,该函数随后会调用 notifyOutputChanged 来更新输出值并随后在 PowerApps Form 上触发 onChange 事件。
推荐阅读
- jquery - 当元素开始在窗口中显示时应用类
- python - Telegram bot API 使用 python-telegram-bot 编辑 InlineKeyboard 不起作用
- java - 如何构建 JPA 查询来计算任意 CriteriaQuery 的结果数?
- node.js - 如何用角度处理heroku中的路由问题?
- mysql - ERROR 1093 (HY000): 您不能在 FROM 子句中指定要更新的目标表
- ffmpeg - concat视频太长ffmpeg
- reactjs - GraphQL 突变:不变违规:必须包含查询定义
- dart - (Flutter) 如何撤消计算器中的算术运算
- r - 识别 R 中值为 0 的行
- networking - Kubernetes:无法访问后端:读取 udp 10.200.0.9:46159->183.60.83.19:53:i/o 超时