Skip to main content

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 = $(‘

’)

.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 = $(‘
’).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 = $(‘
’).append(amt,slider);

field.element.append(sliderContainer);

}


Thx!




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


thank you so much Bill, that worked like a charm!


Appreciate your help