简体   繁体   中英

How to reset a wizard sapui5

I have a wizard that I finish and I want to reset after that and go back to the first step with all other steps invalidated just like it was at first. I can reset the model of my data but I always end up in the last step of wizard

Call the following code in a function that gets called every time you enter the wizard (not onInit , this gets called only once, better would be your onRouteMatched method).

var oWizard = this.byId("myWizard");
var oFirstStep = oWizard.getSteps()[0];
oWizard.discardProgress(oFirstStep);
// scroll to top
oWizard.goToStep(oFirstStep);
// invalidate first step
oFirstStep.setValidated(false);

I guess you are missing the following line to reset progress:

oWizard.discardProgress(
    oWizard.getSteps()[0]
);

Discards all progress done from the given step(incl.) to the end of the wizard.

See here for the API documentation of the discard function. The function needs the first wizardStep as a parameter.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM