【发布时间】:2020-03-02 17:40:48
【问题描述】:
目前我正在模型驱动的应用程序中实现自定义列表。我注意到在过滤数据时调用了 init 方法以及 updateView 方法,此外,updateView 方法被调用了 3 次。但是,新视图并未呈现。
我的猜测是我的组件没有正确排序和处理异步承诺,因此最后的 init 方法会将所有内容重置为原始数据或用原始数据覆盖它。
这样做的正确方法是什么?
- 最初渲染组件(这里我指的是
init或updateView方法中的渲染代码)? - 如果数据被刷新,如何处理异步调用才能再次渲染视图?
目前代码如下:
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);
}
【问题讨论】:
-
您有机会查看我的答案吗?
标签: powerapps react-tsx powerapps-modeldriven powerapps-component-framework