gpt4 book ai didi

powerapps - 在模型驱动的 PowerApps 中使用过滤后的数据 react 渲染新 View

转载 作者:行者123 更新时间:2023-12-04 11:02:21 27 4
gpt4 key购买 nike

目前我正在模型驱动的应用程序中实现自定义列表。我注意到,在过滤数据时,init 方法以及 updateView方法被调用,此外 updateView方法被调用 3 次。但是,不会呈现新 View 。

我的猜测是我的组件没有正确排序和处理异步 promise ,因此 init最后的方法将所有内容重置为原始数据或用原始数据覆盖它。

这样做的正确方法是什么?

  • 最初渲染组件(这里我的意思是 initupdateView 方法中的渲染代码)?
  • 如果刷新数据,如何处理异步调用以再次呈现 View ?

  • 目前,代码如下所示:
         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这将反过来调用 updateView PCF PM words :

    NotifyOutputChange calls the CRM client layer to update the value and it makes the form dirty(save before exit). Additionally all business layer logic like clientAPI, PBL and field validation is kicked in. If this is not needed and the control needs to just change the UI you can skip notifyOutputChange.

    Control reload , page resize and external business logic updating the control value triggers UpdateView.


    在 React 框架中 - 你应该像下面这样:

    we need to create a notifyChange function, which will update the output value of PCF and call the notifyOutputChanged in our PCF component.

    We can pass the notifyChange function to our custom React component as part of props. Whenever a value is updated in our React component, the notifyChange function is executed, which will subsequently call notifyOutputChanged to update the output value and subsequently trigger onChange event on PowerApps Form.


    Learn more

    关于powerapps - 在模型驱动的 PowerApps 中使用过滤后的数据 react 渲染新 View ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58726753/

    27 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com