PCF 在没有调整浏览器大小的情况下不触发 updateview

PCF Not firing updateview without Resize Browser

创建了一个 PCF 控件,在 harnes 工具中运行良好。集成到 D365 后,updateview() 未被调用。单击 developertool 后,它就可以工作了。如果我没有打开开发人员工具或调整浏览器的大小 window,那么即使数据已更改也不会调用 updateview。

Onresetclick 正在调用 notifychanged 事件,虽然它没有触发 updateview

      private onResetClick = (newValue: boolean, props: ToggleProps): void => {


    if (newValue) {
        //isReset true -> clicked set button, action to grey out toggle and change button name to set
        if (!this.changeProps.isControlDisabledInForm) {
            this._isChanged = true;
            this.isReset = this.changeProps.isReset = newValue;
            this.changeProps.buttonProperties.checkbox.disabled = true;
            this.changeProps.buttonProperties.checkbox.checked = false;
            this._selectedOptionID = null;
          //  this.theNotifyChanged(); 


        }

    } else {
        if (!this.changeProps.isControlDisabledInForm) {
            this._isChanged = true;

            this.changeProps.buttonProperties.checkbox.disabled = false;
            this.isReset = this.changeProps.isReset = newValue;
            
            
            this._selectedOptionID
                = this.changeProps.optionsetValues.nokey;
          //  this.theNotifyChanged();

        }

    }
    if (this.theNotifyChanged) {
        this.theNotifyChanged();
    }
};
/**
 * Called when any value in the property bag has changed. This includes field values, data-sets, global values such as container height and width, offline status, control metadata values such as label, visible, etc.
 * @param context The entire property bag availabel to control via Context Object; It contains values as set up by the customizer mapped to names defined in the manifest, as well as utility functions
 */
public updateView(context: ComponentFramework.Context<IInputs>): void {
    this._context = context;
    this.changeProps.isControlDisabledInForm = context.mode.isControlDisabled;
    this.changeProps.isVisible = context.mode.isVisible;
    this._checkboxID = context.parameters.OptionSetAttribute.attributes?.LogicalName ?? uuidv4();
    let selBoolean: boolean = false;
    if (!this._isChanged) {
        this._selectedOptionID = context.parameters.OptionSetAttribute.raw;
       
       
     //   this.SetButtonProperties(selBoolean);
    }
    else {
        //if (this.changeProps.isReset) {
        //    //  this.changeProps.buttonProperties.checkbox.disabled = true;
        //    // this.changeProps.buttonProperties.checkbox.checked = false;

        //}
        //else {
        //    //  this.changeProps.buttonProperties.checkbox.disabled = false;

        //}
        selBoolean = this.isReset as boolean;//this.changeProps.buttonProperties.checkbox.checked;
       
    }
    if (this.optionSetArray) {
        for (var i = 0; i < this.optionSetArray.length; i++) {

            if (this.optionSetArray[i].Value == this._selectedOptionID) {

                this.SelectedOptionSetLabel = this.optionSetArray[i].Label;
            }
            if (this.optionSetArray[i]?.Label.toUpperCase() === "YES") { //TODO :  this needs to be generic not fixed with yes 
                this.changeProps.optionsetValues.yeskey = this.optionSetArray[i].Value;
            } else {
                this.changeProps.optionsetValues.nokey = this.optionSetArray[i].Value;
            }
        }
    }
    if (!this._isChanged) {
        if (this.SelectedOptionSetLabel != null && this.SelectedOptionSetLabel != undefined) {
            this.changeProps.buttonProperties.checkbox.checked = this.SelectedOptionSetLabel?.toUpperCase() === "YES" ? true as boolean : false as boolean;//TODO :  this needs to be generic not fixed with yes
            selBoolean = this.changeProps.isReset = this.isReset = true;
        } else {
            selBoolean = false;
            this.changeProps.isReset = this.isReset = false;
        }
    }
    this._messageContent = selBoolean ? this.changeProps.labels.trueLabel : this.changeProps.labels.falseLabel;
    this.changeProps.buttonProperties = {
        resetButton: { innerHTML: selBoolean ? "Reset" : "Set" },// when there is a value stored in attribute we need to show Reset
        messageContent: this._messageContent,
        checkbox: {
            disabled: this.changeProps.isControlDisabledInForm ? true : (this.isReset ? false : true),
            checked: this.changeProps.buttonProperties.checkbox.checked, checkboxID: this._checkboxID
        }
    };
    console.log("inside ts");
    ReactDOM.render(
        React.createElement(ToggleButton, this.changeProps

        ), this.container);
}

虽然上下文发生了变化,但范围转到 getOutput() 方法以检查输出是否有任何变化,然后只有 PCF 视图得到重新呈现。就我而言,我没有更改 getoutput() 方法中的输出值,因此它不起作用。 这里的“_selectedOptionID”值应该改变然后它开始工作。

public getOutputs(): IOutputs {
        return {
            OptionSetAttribute: this._selectedOptionID as number
        };
    }