If you have technical questions, please create a support ticket in the DevExpress Support Center.
<div class="form">
<div class="dx-fieldset">
<div class="dx-field">
<div class="dx-field-label">Default mode</div>
<div class="dx-field-value">
Html.DevExtreme().RangeSlider() (
.Min(0)
.Max(100)
.Start(20)
.End(60)
)
</div>
</div>
<div class="dx-field custom-height-slider">
<div class="dx-field-label">With labels</div>
<div class="dx-field-value">
Html.DevExtreme().RangeSlider() (
.Min(0)
.Max(100)
.Start(35)
.End(65)
.Label(l => l
.Visible(true)
.Format(new JS("formatLabel"))
.Position(VerticalEdge.Top)
)
)
</div>
</div>
<div class="dx-field custom-height-slider">
<div class="dx-field-label">With tooltips</div>
<div class="dx-field-value">
Html.DevExtreme().RangeSlider() (
.Min(0)
.Max(100)
.Start(15)
.End(65)
.Tooltip(t => t
.Enabled(true)
.Format(new JS("formatLabel"))
.ShowMode(SliderTooltipShowMode.Always)
.Position(VerticalEdge.Bottom)
)
)
</div>
</div>
<div class="dx-field">
<div class="dx-field-label">Without range highlighting</div>
<div class="dx-field-value">
Html.DevExtreme().RangeSlider() (
.Min(0)
.Max(100)
.Start(20)
.End(80)
.ShowRange(false)
)
</div>
</div>
<div class="dx-field">
<div class="dx-field-label">With discrete step</div>
<div class="dx-field-value">
Html.DevExtreme().RangeSlider() (
.Min(0)
.Max(100)
.Start(20)
.End(70)
.Step(10)
.Tooltip(t => t.Enabled(true))
)
</div>
</div>
<div class="dx-field">
<div class="dx-field-label">Disabled</div>
<div class="dx-field-value">
Html.DevExtreme().RangeSlider() (
.Min(0)
.Max(100)
.Start(25)
.End(75)
.Disabled(true)
)
</div>
</div>
</div>
<div class="dx-fieldset">
<div class="dx-fieldset-header">Process Value Changes</div>
<div class="dx-field">
<div class="dx-field-label">On handle movement</div>
<div class="dx-field-value">
Html.DevExtreme().RangeSlider() (
.ID("slider-on-handle-move")
.Min(0)
.Max(100)
.Start(10)
.End(90)
.OnValueChanged("rangeSlider_valueChanged")
)
</div>
</div>
<div class="dx-field">
<div class="dx-field-label">On handle release</div>
<div class="dx-field-value">
Html.DevExtreme().RangeSlider() (
.ID("slider-on-handle-move")
.Min(0)
.Max(100)
.Start(10)
.End(90)
.ValueChangeMode(SliderValueChangeMode.OnHandleRelease)
.OnValueChanged("rangeSlider_valueChanged")
)
</div>
</div>
<div class="dx-field">
<div class="dx-field-label">Start value</div>
<div class="dx-field-value">
Html.DevExtreme().NumberBox() (
.ID("start-value")
.Value(10)
.Min(0)
.Max(100)
.ShowSpinButtons(true)
.InputAttr("aria-label", "Start Value")
.OnValueChanged("startValue_changed")
)
</div>
</div>
<div class="dx-field">
<div class="dx-field-label">End value</div>
<div class="dx-field-value">
<div id="end-value"></div>
Html.DevExtreme().NumberBox() (
.ID("end-value")
.Value(90)
.Min(0)
.Max(100)
.InputAttr("aria-label", "End Value")
.ShowSpinButtons(true)
.OnValueChanged("endValue_changed")
)
</div>
</div>
</div>
</div>
<script>
function formatLabel(value) {
return value + "%";
}
function getOnHandleMoveSliderInstance() {
return $("#slider-on-handle-move").dxRangeSlider("instance");
}
function getOnHandleReleaseSliderInstance() {
return $("#slider-on-handle-release").dxRangeSlider("instance");
}
function rangeSlider_valueChanged(data) {
$("#start-value").dxNumberBox("instance").option("value", data.start);
$("#end-value").dxNumberBox("instance").option("value", data.end);
}
function startValue_changed(data) {
getOnHandleMoveSliderInstance().option("start", data.value);
getOnHandleReleaseSliderInstance().option("start", data.value);
}
function endValue_changed(data) {
getOnHandleMoveSliderInstance().option("end", data.value);
getOnHandleReleaseSliderInstance().option("end", data.value);
}
</script>
xxxxxxxxxx
xxxxxxxxxx
Create a RangeSlider
To create a RangeSlider, declare it in markup and specify the following four properties:
You can see the resulting RangeSlider in the Default mode section of this demo.
Customize RangeSlider Appearance
The RangeSlider can display labels for the min and max values. To configure the labels, use the label object. In this object, set the visible property to true
to display the labels. You can also specify the position and format properties.
The RangeSlider can also display a tooltip for slider handles. To display tooltips, you need to configure the tooltip object:
-
Set the enabled property to
true
to display tooltips. -
Specify the tooltip position.
-
Specify the format property.
-
Assign 'onHover' or 'always' to the showMode property to change how the component shows tooltips.
Use the showRange property to specify if the selected range should be highlighted. You can also use the step property to specify the value change step for the RangeSlider.
If you want to disable the RangeSlider, set the disabled property to true
.
Handle the Value Change Event
Specify the onValueChanged function to handle the value change. In this demo, the NumberBox components and the RangeSlider use this property to exchange values.
The valueChangeMode property allows you to choose when to change the RangeSlider value and supports the onHandleMove
and onHandleRelease
modes. You can see the property's effect in the Process Value Changes section. The first RangeSlider changes its value every time a user slides the handle. The second RangeSlider changes its value only when the handle is released. These RangeSlider values are synchronized.