Change WizardStep button text

亡梦爱人 提交于 2019-12-22 17:09:14

问题


How can I rename the button text (default "step 1" till "step n") of each WizardStep?.

For the entire Wizard the text of the finish button can be set by setting the property finishButtonText. But there is no similar property for the WizardStep.


回答1:


There is no robust, proper way of changing the next button text (that I could find).

But here are two workarounds that might help while someone else gives a better answer:

The "next button" is the last control of the content of the current wizard step

myWizardStep.getContent()[lastIndex].setText("new text"); /*note that after the button is pressed, the control will no longer be a part of the WizardStep, and lastIndex won't reference the button's index anymore*/

Another (not great) solution: The generated id of the button is the id of the Wizard (not the WizardStep) + -nextButton. So if you have a wizard __xmlview13--myWizard, the next button will always be __xmlview13--myWizard-nextButton, which you can get using sap.ui.getCore().byId(nextButtonId)and then .setText(), etc.

Both workarounds are just a temporary solution, and the button text will change after being pressed, because you are working with the same instance of Button.




回答2:


Did you look up the explored reference for the Wizard control? Each Wizard Step title can be edited via the "title" parameter https://sapui5.hana.ondemand.com/explored.html#/sample/sap.m.sample.Wizard/preview

Otherwise please give a code example from your application




回答3:


There is no standard way. Here is how I achieved it.

Step 1. Deactivate the standard buttons using showNextButton="false" on the Wizard control. Step 2. In each of the WizardSteps' content, have your own buttons (As the last control) with the required text. Step 3. In the press event of the custom buttons you added, do the validation (consider using API validateStep) and call nextStep() API of the Wizard control.



来源:https://stackoverflow.com/questions/45097994/change-wizardstep-button-text

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!