I'm struggling to append sheets names to a Bootstrap Table. My Apps Script Sidebar is called with sidebarSM() function:
function sidebarSM() {
let html = HtmlService.createTemplateFromFile('public/sheets');
html.wsNames = getWorksheetNames();
html = html.evaluate(); ui().showSidebar(html)
}
The code.gs function:
function getWorksheetNames() {
let sheetNames = new Array();
let sheets = SpreadsheetApp.getActive().getSheets();
for (let i = 0 ; i < sheets.length ; i++) sheetNames.push( { name: sheets[i].getName() } )
return sheetNames;
}
And frontend html:
<script>
WorksheetDeleteApp.loadWorksheetNames = function() {
let wsNames = JSON.parse("<?=JSON.stringify(wsNames)?>");
let $table = $('#table-sm');
$table.bootstrapTable('append', wsNames);
}
$(document).ready(function() {
WorksheetDeleteApp.loadWorksheetNames()
});
</script>
I tried to pass the return with google.script.run in the html and it append the names, but it takes many seconds so I'm working with this JSON.parse("<?=JSON.stringify(wsNames)?>"); scripplet. wsNames variable shows correctly the names in a window.alert(), but dont append the names to the table. Any help?
Thanks.