I would like to populate array data in modal box, then have the user assign the category from a predefined drop down located under the Category column. My blocking issue is understanding how to move data from getRangeValues() found in .gs to the .html file.
The html code body is add for visual purposes. In my head the javascript code would generate a p tag (or another tag) for each record that is in the 2D array.
function activateModal() {
let sheet = SpreadsheetApp.getActiveSpreadsheet().getSheetByName('test');
let html = HtmlService.createHtmlOutputFromFile('forStack');
html.setWidth(800).setHeight(500);
let ui = SpreadsheetApp.getUi().showModalDialog(html, 'Assign Categories')
}
function getRangeValues() {
let sheet = SpreadsheetApp.getActiveSpreadsheet().getSheetByName('test');
let range = sheet.getRange(1, 1, sheet.getLastRow(), sheet.getLastColumn())
let values = range.getValues();
// Logger.log(values);
}
function fromHTMLFileData() {
"brings data from HTML file function."
}
<!DOCTYPE html>
<html>
<head>
<base target="_top">
</head>
<body>
<table>
<thead>
<tr>
<th>Item</th>
<th>Price</th>
<th>Quantity</th>
<th>Category</th>
</tr>
</thead>
<tbody>
<tr>
<td>Apples</td>
<td>0.50</td>
<td>10</td>
<td></td>
</tr>
<tr>
<td>Pears</td>
<td>1.00</td>
<td>10</td>
<td></td>
</tr>
<tr>
<td>Carrots</td>
<td>1.50</td>
<td>70</td>
<td></td>
</tr>
<tr>
<td>Peanuts</td>
<td>2.50</td>
<td>1</td>
<td></td>
</tr>
</tbody>
</table>
<script>
"How do I call the data from "test" sheet function getRangeValues()?"
script.google.run<function()> sends data to the .gs function.
</script>
</body>
</html>