New to Telerik UI for ASP.NET CoreStart a free 30-day trial

Reversing the Slider Labels to be Displayed from Maximum to Minimum

Environment

ProductTelerik UI for ASP.NET Core Slider
Product Version2024.4.1112

Description

By design, the Slider values are positioned from the minimum value to the maximum value (left to right). How can I reverse the minimum and maximum values of the Slider so the maximum value is displayed on the left and the minimum on the right?

Solution

  1. Set the Min() option to -10 and the Max() value to -1.
  2. Set the initial value to -10.
  3. Update the default Tooltip template to show the absolute value (for example, 10 instead of -10).
  4. Update the Slider labels to show the absolute values when the page with the Slider is loaded.
Razor
    @(Html.Kendo().Slider()
        .Name("reversedSlider")
        .Min(-10)
        .Max(-1)
        .LargeStep(1)
        .Value(-10)
        .Tooltip(x => x.Template("#= Math.abs(value)#"))
    )

When you need to get the Slider's value, use its absolute value:

Html
    <script>
        var slider = $("#reversedSlider").data("kendoSlider");
        var sliderValue = Math.abs(slider.value());
    </script>

For a runnable example based on the code above, refer to the following REPL samples:

More ASP.NET Core Slider Resources

See Also