sap.m.Wizard中的动态步骤添加/删除

时间:2019-10-30 12:06:48

标签: sapui5

我有一个包含2个步骤的向导。我想根据第二步中的用户选择向向导添加/删除步骤,并更新向导(向向导添加更多步骤或删除步骤)。尝试从向导中删除步骤后,我将无法正确呈现视图。删除步骤后,我将失去整个视图,向导将显示为空白,没有任何步骤。

  1. 我尝试使用bindAggregation并添加了向导步骤作为模板
  2. 我尝试使用方法addWizardStep添加一个步骤。

我的观点:

<Wizard id="idCOEWizard" complete="wizardCompletedHandler" steps="{wizardSteps>/steps}" showNextButton="false">
    <WizardStep id="idCOESteps" title="{wizardSteps>stepTitle}" validated="{wizardSteps>validated}" activate="onStepActivate">
        <core:Fragment fragmentName="" type="XML"/>
        <core:Fragment fragmentName="" type="XML"/>
        <core:Fragment fragmentName="" type="XML"/>
    </WizardStep>
</Wizard>

步数数据:

{
    "steps": [{
        "id": "EmployeeDetails",
        "stepTitle": "Employee Details",
        "validated": true,
        "sortOrder": 1,
        "viewFrag": "EmployeeDetails"
    }, {
        "id": "TypeofChange",
        "stepTitle": "Type of Change",
        "validated": true,
        "sortOrder": 2,
        "viewFrag": "TypeOfChange"
    }]
}

代码:

var aCurrentSteps = this.getView().getModel("wizardSteps").getProperty("/steps");
var oWizardSteps = this.byId("idCOESteps");
for (var i = 0; i < aCurrentSteps.length; i++) {
    if (sStep === aCurrentSteps[i].id) {
      aCurrentSteps.splice(i);
    }
}
this.byId("idCOEWizard").removeAllSteps();
this.byId("idCOEWizard").bindAggregation("steps", {
    path: "{wizardSteps>/steps}",
    template: oWizardSteps
});
this.byId("idCOEWizard").discardProgress(this.byId("idCOEWizard").getSteps()[0]);
this.getView().getModel("wizardSteps").refresh(true);

0 个答案:

没有答案