Skip to content

Commit 0341f5b

Browse files
ntachevadimodi
andauthored
chore(stepper):added OnChange event (#397)
* chore(stepper):added OnChange event * Update components/stepper/events.md Co-authored-by: Dimo Dimov <961014+dimodi@users.noreply.github.com> * Update components/stepper/events.md Co-authored-by: Dimo Dimov <961014+dimodi@users.noreply.github.com> Co-authored-by: Dimo Dimov <961014+dimodi@users.noreply.github.com>
1 parent 90113df commit 0341f5b

File tree

2 files changed

+53
-2
lines changed

2 files changed

+53
-2
lines changed

components/stepper/events.md

Lines changed: 53 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,58 @@ position: 25
1010

1111
# Stepper Events
1212

13-
This article explains the events available in the Telerik Stepper for Blazor
13+
This article explains the events available in the Telerik Stepper for Blazor:
14+
15+
* [OnChange](#onchange)
16+
* [ValueChanged](#valuechanged)
17+
18+
## OnChange
19+
20+
The `OnChange` event fires before the current step has changed. The handler receives an object of type `StepperStepChangeEventArgs` which exposes the following fields:
21+
22+
* `TargetIndex` - provides the index of the targeted new step.
23+
* `IsCancelled` - specifies whether the event is canceled and the built-in action is prevented.
24+
25+
>caption Handle the `OnChange` event of the first and second steps. The result from the snippet below.
26+
27+
28+
![OnChange](images/onchange-example.gif)
29+
30+
````CSHTML
31+
@* Handle the OnChange event of the steps *@
32+
33+
Next targeted step index: @TargetIndex
34+
35+
<div style="width:500px">
36+
<TelerikStepper>
37+
<StepperSteps>
38+
<StepperStep Text="1" OnChange="@OnChangeHandler1" ></StepperStep>
39+
<StepperStep Text="2" OnChange="@OnChangeHandler2"></StepperStep>
40+
<StepperStep Text="3"></StepperStep>
41+
</StepperSteps>
42+
</TelerikStepper>
43+
</div>
44+
45+
@code{
46+
public int? TargetIndex { get; set; } = null;
47+
48+
async Task OnChangeHandler1(StepperStepChangeEventArgs args)
49+
{
50+
TargetIndex = args.TargetIndex;
51+
}
52+
53+
async Task OnChangeHandler2(StepperStepChangeEventArgs args)
54+
{
55+
args.IsCancelled = true;
56+
57+
await Dialog.AlertAsync("Please complete step 2 first", "You cannot proceed");
58+
59+
}
60+
61+
[CascadingParameter]
62+
public DialogFactory Dialog { get; set; }
63+
}
64+
````
1465

1566

1667
## ValueChanged
@@ -48,4 +99,4 @@ The Telerik Stepper for Blazor supports ValueChanged event. It fires upon every
4899

49100
## See Also
50101

51-
* [Live Demo: Stepper Events](https://demos.telerik.com/blazor-ui/stepper/events)
102+
* [Live Demo: Stepper Events](https://demos.telerik.com/blazor-ui/stepper/events)
88 KB
Loading

0 commit comments

Comments
 (0)