Skip to content

Commit b72832c

Browse files
docs(tabStrip): cancel its event
1 parent dcbbddf commit b72832c

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed

components/tabstrip/events.md

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,38 @@ The `ActiveTabIndexChanged` event fires when the user changes the tab that is cu
4444
}
4545
````
4646

47+
>caption Cancel the event
48+
49+
````CSHTML
50+
@* If the tab strip is bound to a field in the view model, when you do not update that field in the event handler, you will effectively cancel the event *@
51+
52+
<TelerikTabStrip ActiveTabIndex="@ActiveTabIndex" ActiveTabIndexChanged="@TabChangedHandler">
53+
<TabStripTab Title="First">
54+
First tab content. Click through the tabs.
55+
</TabStripTab>
56+
<TabStripTab Title="Second">
57+
Second tab content.
58+
</TabStripTab>
59+
<TabStripTab Title="Third">
60+
Third tab content.
61+
</TabStripTab>
62+
</TelerikTabStrip>
63+
64+
@code {
65+
int ActiveTabIndex { get; set; }
66+
67+
void TabChangedHandler(int newIndex)
68+
{
69+
// this will update the view-model for all items but the third,
70+
// effectively cancelling the event for the third tab
71+
if (newIndex != 2)
72+
{
73+
ActiveTabIndex = newIndex;
74+
}
75+
}
76+
}
77+
````
78+
4779
## See Also
4880

4981
* [TabStrip Overview]({%slug components/tabstrip/overview%})

0 commit comments

Comments
 (0)