Skip to content

Commit

Permalink
chore(NumericTextBox): apply comments suggestions
Browse files Browse the repository at this point in the history
  • Loading branch information
xristianstefanov committed Oct 4, 2024
1 parent 7cee110 commit 04960f2
Showing 1 changed file with 13 additions and 11 deletions.
24 changes: 13 additions & 11 deletions knowledge-base/numerictextbox-disable-arrows.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
title: Disabling NumericTextBox Arrows at Min or Max Value in Blazor
title: Disable NumericTextBox Arrows at Min or Max Value in Blazor
description: Learn how to programmatically disable the increase or decrease arrows of a NumericTextBox in Blazor when the value reaches its minimum or maximum limit.
type: how-to
page_title: How to Disable NumericTextBox Arrows on Min or Max Value in Blazor
Expand All @@ -22,7 +22,7 @@ ticketid: 1665216

## Description

When using the NumericTextBox with arrows enabled, I want to disable the down arrow programmatically at the component's minimum value to prevent looping to the maximum value.
In a NumericTextBox with enabled arrows, I want to disable the down arrow programmatically at the component's minimum value to prevent looping to the maximum value.

This KB article answers the following questions:

Expand All @@ -31,10 +31,12 @@ This KB article answers the following questions:

## Solution

To prevent the increase/decrease arrows of the NumericTextBox from being used when the numeric value reaches its minimum or maximum, apply a conditional CSS class to disable the buttons.
To prevent your end users from looping through the minimum and maximum values with the icnrease/decrease arrows of the NumericTextBox, apply a conditional CSS class to disable the buttons.

The example below demonstrates how to conditionally render CSS styles to disable the increase or decrease arrows based on the current value of the NumericTextBox.

>caption The Min and Max values should not match the default minimum and maximum values of the Value type.
````CSHTML
<style>
.disable-increase .k-spinner-increase,
Expand All @@ -44,19 +46,19 @@ The example below demonstrates how to conditionally render CSS styles to disable
}
</style>
<TelerikNumericTextBox @bind-Value="@theValue"
Min="@minValue"
Max="@maxValue"
Class="@numericClass"
<TelerikNumericTextBox @bind-Value="@NumericValue"
Min="@MinValue"
Max="@MaxValue"
Class="@NumericClass"
Width="300px">
</TelerikNumericTextBox>
@code {
private int theValue { get; set; } = 3;
private int minValue { get; set; } = 1;
private int maxValue { get; set; } = 10;
private int NumericValue { get; set; } = 3;
private int MinValue { get; set; } = 1;
private int MaxValue { get; set; } = 10;
private string numericClass => $"disable-arrows {(theValue == maxValue ? "disable-increase" : "")} {(theValue == minValue ? "disable-decrease" : "")}";
private string NumericClass => $"{(NumericValue == MaxValue ? "disable-increase" : "")} {(NumericValue == MinValue ? "disable-decrease" : "")}";
}
````

Expand Down

0 comments on commit 04960f2

Please sign in to comment.