Quantcast
Channel: Recent Discussions — DataTables forums
Viewing all articles
Browse latest Browse all 82031

DataTable population using google script call function

$
0
0

So I'm working with a Google Script. The script pulls information from a google spreadsheet and should be displaying it in the datatable. The table is creating correctly and using the columns I've defined, the data just isn't pulling in. When I debug my script the dataset is populated and should be returned from the function.

Are data tables able to be loaded from a function returning the dataset?

<script>
$(document).ready(function() {
        $('#customerlist').DataTable( {
            data: google.script.run.getData(),
            columns: [
              { title: "Company" },
              { title: "Service Type" },
              { title: "Email" },
              { title: "Contact1" },
              { title: "Cell #" },
              { title: "Contact 2" },
              { title: "Cell #" },
              { title: "Contact 3" },
              { title: "Cell #" },
              { title: "Contact 4" },
              { title: "Cell #" },
              { title: "Contact 5" },
              { title: "Cell #" },
              { title: "Contact 6" },
              { title: "Cell #" },
              { title: "Contact 7" },
              { title: "Cell #" },
              { title: "Contact 8" },
              { title: "Cell #" },
              { title: "Contact 9" },
              { title: "Cell #" }
            ]
        } );
      } );
    </script>

function getData(){
  var id = "abc";
  var sheetname = "Master";
  var dataSet = SpreadsheetApp.openById(id).getSheetByName(sheetname).getDataRange().getValues();
  
  return dataSet;
}

Viewing all articles
Browse latest Browse all 82031

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>