Programmatically enable or disable wizard buttons

1 Answer 1334 Views
Wizard
Lynn
Top achievements
Rank 1
Iron
Lynn asked on 28 Sep 2021, 11:54 AM

I've been searching for a while now and I can't find any resources on this. Enabling or disabling a button initially can be done through the button config: https://docs.telerik.com/kendo-ui/api/javascript/ui/wizard/configuration/steps.buttons.enabled

But there seems to be no documentation on how to programmatically enable or disable these buttons. What's the best way of doing so?

1 Answer, 1 is accepted

Sort by
1
h
Top achievements
Rank 1
Iron
answered on 30 Sep 2021, 09:26 AM

Hi,

Below is how I enable/disable the step buttons:

$("#wizard").data("kendoWizard").steps()[1].buttons()[1].enable(true);

Hope this helps.

Lynn
Top achievements
Rank 1
Iron
commented on 30 Sep 2021, 10:01 AM

Yes, that did it for me, thanks!

I wonder if there's a way where I can somehow bind a model to it? That way I could do something like `nextButton.set("enabled", false)`. It feels really nasty to have to reference outside variables or use jquery selectors to call this code, also makes it really hard to write re-usable code.


(e) => {
    const step1Buttons = someWizard.steps()[1].buttons();
    const step2Buttons = someWizard.steps()[2].buttons();

    if (e.something) {
        step1Buttons[1].enable(true);
        step1Buttons[2].enable(true);
        step2Buttons[1].enable(true);

        return;
    }

    step1Buttons[1].enable(false);
    step1Buttons[2].enable(false);
    step2Buttons[1].enable(false);
};

Martin
Telerik team
commented on 01 Oct 2021, 10:09 AM

You can use the active event where you have access to the e.step object. You can then use a field set in the step configuration to determine whether to enable the buttons or not. Here is a small example for reference.
Tags
Wizard
Asked by
Lynn
Top achievements
Rank 1
Iron
Answers by
h
Top achievements
Rank 1
Iron
Share this question
or