I have seen examples on how to create a dropdown list based on values coming from Range values from other spreadsheets, dropdown list depending on a cell value. In all examples i have seen, values were coming from range values from other spreadsheets.
What i want to achieve is :
- in a spreadsheet with column headers, i have no line.
- when i edit the 1st cell, it shows a dropdown list with values. Only when i edit the cell. If possible i would like not to pre-populate a the cell of the st column for a fixed number of rows, cause i am thinking this may consumes time, and i do not know how many cells there will be there in the file in one month.
- values from the dropdown list are retrieved from another Google Workspace Service.
What i experienced at the moment :
- I am able to retrieve the values i want to display in my dropdown list
- If i am right, to construct a dropdown list, there is to use the SpreadsheetApp.newDataValidation() method to build the dropdown list
- My values are stored in a 2 dimensional array, as it seems this would be the way to pass the values to a range of cells that is passed into parameter of the previous method, with the Build method at the end
- i was able to set the values for a range of cells (ex: A1:A10) and display a dropdown list icon on each cell, but the values displayed when editing the cells are like val1;val2;val3...
My questions :
- How do i create a dynamic dropdown list on the cell of the 1st column, dynamically, when i edit the cell ? If the cell of the 1st colum has to be prefilled, then at least why not
I do not know if iwa clear enough. This is the idea of the script :
var v_spreadsheet = SpreadsheetApp.getActiveSpreadsheet();
var v_sheet = v_spreadsheet.getActiveSheet();
// I imagine i could specify A1:A1 to specify only the cell that is being edited ?
var range = v_sheet.getRange("A2:A5");
// my array below is 2 dimensions : v_array[0][0] = 'val1', v_array[0][1] = 'val2', etc
range.setValues(v_array_taskLists);
var dd_values = range.getValues();
var validationRule = SpreadsheetApp.newDataValidation().requireValueInList(dd_values).build();
range.setDataValidation(validationRule);
As you can see i am passing by a range data, which may not be the correct way
Any help greatly appreciated Many thanks in advance