In a trigger fired after the Dynaform, you can use code like this:
Code: Select allif (!empty(@=myGrid)) {
for ($i =1; $i < count(@=myGrid); $i++) {
//if no option selected in "myDropdown" field in grid for row number $i:
if (@=myGrid[$i]['myDropdown'] == '') {
//not sure what you want to do here. Am setting to the value:
@=myGrid[$i]['myDropdown'] = 'some value';
//if wanting to throw an exception:
//throw new Exception("Error: The dropdown value in row $i can't be empty!");
//if wanting to display a message to user:
//$g = new G();
//$g->SendMessageText("Error: The dropdown value in row $i can't be empty!", "ERROR");
}
}
}
If wanting to do it in JavaScript:
Code: Select allvar dropdownColNo = 3; //set to column number of dropdown in grid; Counting starts from 0
var formId = $("form").prop(" id");
$("#" +formId).setOnSubmit( function() {
aGridVals = $("#myGrid").getValue();
for(var rowNo in aGridVals) {
if (aGridVals[rowNo][dropdownColNo] == '') {
alert("Dropdown in row "+(rowNo+1)+" is empty!);
//if wanting to set to a default value:
//add 1 because counting columns and rows starts from 1, not 0.
$("#myGrid").setValue("default value" , rowNo+1, dropdownColNo+1);
}
}
});