How to remove decimals in Slider Min and Max values

Created on 19 July 2024, about 2 months ago
Updated 29 August 2024, 9 days ago

Problem/Motivation

After upgrading Better Exposed Filters module to version 6.0.6, an exposed views filter using the Better Exposed Filters sliders widget is showing decimals for the Min and Max value such as 5.00 and 10.00. I don't want any decimals showing and unable to determine where in the admin interface or the module code that needs changing so that the values display as 5 and 10 (with no decimals).

Proposed resolution

Maybe an option in the interface for the sliders widget to specify how many decimals to display.

πŸ’¬ Support request
Status

Closed: outdated

Version

7.0

Component

Code

Created by

πŸ‡¨πŸ‡¦Canada Debra

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

  • Issue created by @Debra
  • πŸ‡¨πŸ‡¦Canada Debra

    I was able to remove the decimals by modifying bef_sliders.js and in the format setting when creating the slider, apply the parseInt function to the 'to' and 'from' values.

    noUiSlider.create(slider, {
                  range: {
                    'min': parseFloat(sliderOptions.min),
                    'max': parseFloat(sliderOptions.max)
                  },
                  step: parseFloat(sliderOptions.step),
                  animate: !!sliderOptions.animate,
                  animationDuration: parseInt(sliderOptions.animate),
                  orientation: sliderOptions.orientation,
                  start: [defaultMin, defaultMax],
                  format: {
                    // 'to' the formatted value. Receives a number.
                    to: function (value) {
                      //return Math.trunc(Number(value));
                      return parseInt(value);
                    },
                    // 'from' the formatted value.
                    from: function (value) {
                     // return Math.trunc(Number(value));
                     return parseInt(value);
    

    It would be nice if this was a setting in the Exposed Filter Settings section of the view.

  • πŸ‡ΊπŸ‡ΈUnited States smustgrave

    Can you test 7.0.x

  • πŸ‡ΊπŸ‡ΈUnited States smustgrave

    Can you check if issue on 7.0.x branch?

  • Status changed to Postponed: needs info about 1 month ago
  • πŸ‡ΊπŸ‡ΈUnited States smustgrave
  • Status changed to Closed: outdated 9 days ago
  • πŸ‡ΊπŸ‡ΈUnited States smustgrave

    If experiencing on 7.0.x branch please reopen.

Production build 0.71.5 2024