Reputation: 415
When I set a cells data validation from script I would like to set which of the choices is displayed by default, currently the data validation is written to the sheet with no item selected using code below. Is there any way to set it to "Vote"?
var option = new Array();
option[0]="Vote";
option[1]="Vote Up";
option[2]="Vote Down";
var dv = SpreadsheetApp.newDataValidation();
dv.setAllowInvalid(false);
dv.setHelpText("Vote this item up or down.");
dv.requireValueInList(option, true);
localSheet.getRange(1,6).setDataValidation(dv.build());
Upvotes: 2
Views: 5310
Reputation: 38218
Use setValue(value). I.E. add the following line to your code:
localSheet.getRange(1,6).setValue("Vote");
Upvotes: 2