Currently I am implementing a custom list in a model driven app. I noticed that while filtering the data the init method as well as the updateView method is called, furthermore the updateView method is called 3 times. However, the new view is not rendered.
My guess is that the async promises are not correctly ordered and processed by my components, so that the init method at the end resets everything to or overwrites it with the original data.
What would be the right way to do this?
- Initially render the components (by this I mean the render code in the
initorupdateViewmethod)? - if the data is refreshed, how do the async calls have to be processed to render the view again?
Currently the code looks like the following:
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);
}