目前我正在模型驱动的应用程序中实现自定义列表。我注意到在过滤数据时调用了 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);
}