By dipolediamond - Tue May 31, 2016 12:45 pm
- Tue May 31, 2016 12:45 pm
#785582
I am using ProcessMaker 3.0.1.8-community and trying to generate a dropdown list in a grid based on the value set in another column in the grid.
If the value is 10 for example, the column with the dropdown (select) control is modified to have 10 options.
The generating of the options works and when the form is submitted, I can see the selected value in the grid array. However, when the form is loaded, the selected value is reset to null and does not show as selected on the form.
How can I get the selected value and set it when redisplaying the form?
If the value is 10 for example, the column with the dropdown (select) control is modified to have 10 options.
The generating of the options works and when the form is submitted, I can see the selected value in the grid array. However, when the form is loaded, the selected value is reset to null and does not show as selected on the form.
How can I get the selected value and set it when redisplaying the form?
Code: Select all
Every help will be greatly appreciated.function setDropDownSelect(gridId, prefix) {
var aGridVals = $('#'+gridId).getValue();
//loop through grid and get the value for staffScore and maxScore on each row
for (var i = 1; i <= aGridVals.length; i++) {
var currValue = aGridVals[i-1][4];
console.log(gridId + ' --- ' + i + ' --- ' + aGridVals + ' --- ' + currValue);
var maxScore = $("#form\\[" + gridId + "\\]\\[" + i + "\\]\\[" + prefix + "_maxScore\\]").val();
var selector = "select#form\\[" + gridId + "\\]\\[" + i + "\\]\\[" + prefix + "_staffScore\\]";
//$(selector).append('<option value="">Select</option>'); //set empty selector
for (var j = 0; j <= maxScore; j++) {
if( j == currValue ) {
$(selector).append('<option selected="selected" value="' + j + '">' + j + '</option>');
}
else {
$(selector).append('<option value="' + j + '">' + j + '</option>');
}
}
}
}
function initialize() {
setDropDownSelect('peopleManagement','pmg');
setDropDownSelect('financialSoundness','fsg');
setDropDownSelect('globalness','gg');
setDropDownSelect('productQuality','pqg');
setDropDownSelect('serviceQuality','sqg');
setDropDownSelect('innovation','ig');
setDropDownSelect('community','cg');
}
initialize();