slider using fields for minimum and max value

  • 1
  • Question
  • Updated 2 weeks ago
  • Answered
Hi guys I have the JS needed to create sliders, but JS noob that i am, wondering if there is  way to use existing fields in same model to set the minimum and max value

So example below I want to replace:
the min value(1.001) with a field named min_cost__c
the max value(1.999) with a field named max_cost__c

anyone would be kind enough to help me with this please?

var params = arguments[0],
$ = skuid.$;
var field = arguments[0],   
    value = arguments[1],
    $ = skuid.$;
if (field.mode == 'read') {
    skuid.ui.fieldRenderers.DOUBLE.read(field,value);
} else if (field.mode == 'edit') {
    var amt = $('<div class="nx-fieldtext">')
        .text(skuid.ui.renderers.DOUBLE.read({ value: value || '0' }));
    // Render a jQuery ui slider 
    // with step size 1 and boundary range [0,10].
    // Whenever this slider is updated,
    // our row will be updated as well
    var slider = $('<div>').slider({
        value:value || 0,
        min: 1.001,
        max: 1.999,
        step: 0.001,
        slide: function( event, ui ) {
            // Update our model with the new value
            field.model.updateRow(
                field.row,
                field.id,
                ui.value,
                { initiatorId : field._GUID}
            );
            amt.text(skuid.ui.renderers.DOUBLE.read({ value: ui.value,
            decimalPlaces: 3
            }));
        }
    });
    var sliderContainer = $('<div>').append(amt,slider);
    field.element.append(sliderContainer);
}


Thx!
Photo of Dave

Dave

  • 5,600 Points 5k badge 2x thumb

Posted 2 weeks ago

  • 1
Photo of Bill McCullough

Bill McCullough, Champion

  • 12,758 Points 10k badge 2x thumb
Dave,

If the fields 'min_cost__c' and 'max_cost__c' are on the same row, you can pull those values from the 'field' variable you have set.  Like so....

        min: field.row.min_cost__c,
        max: field.row.max_cost__c,

Thanks,

Bill

Photo of Dave

Dave

  • 5,600 Points 5k badge 2x thumb
thank you so much Bill, that worked like a charm!

Appreciate your help