How to remove decimals in Slider Min and Max values

Created on 19 July 2024, 4 months 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

Active

Version

6.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 4 months ago
  • Status changed to Closed: outdated 3 months ago
  • 🇺🇸United States smustgrave

    If experiencing on 7.0.x branch please reopen.

  • 🇮🇳India karamveersingh

    still facing similar decimal issue even after upgrading BEF to release 7.0 on Drupal 10

  • 🇺🇸United States smustgrave

    Still not able to replicate.

  • Status changed to Closed: cannot reproduce 6 days ago
  • 🇬🇧United Kingdom mike-kelly

    The issue occurs when making a range widget: in bef_sliders.js this is the case where $inputs.length = 2. In that case the float values are not truncated.

Production build 0.71.5 2024