Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9269167
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T15:02:51+00:00 2026-06-18T15:02:51+00:00

I am trying to use an array as the datasource using HtmlService and the

  • 0

I am trying to use an array as the datasource using HtmlService and the Datatables plugin for jquery. I am having trouble passing an array. The resulting table is not rendering the array correcty – in this 3 col table, col1 contains ‘1’, col2 contains ‘,’ col3 contains ‘2’ What am I doing wrong?

function doGet() { 
var temp = HtmlService.createTemplateFromFile('example2');
temp.j = [1,2,3];            
return temp.evaluate();  
}

<html>
<head>
    <meta http-equiv="content-type" content="text/html; charset=utf-8" />

    <title>DataTables example</title>

    <link rel="stylesheet" type="text/css" href="http://ajax.aspnetcdn.com/ajax/jquery.dataTables/1.9.1/css/jquery.dataTables.css">
    <script type="text/javascript" charset="utf8" src="http://ajax.aspnetcdn.com/ajax/jQuery/jquery-1.7.1.min.js"></script>
    <script type="text/javascript" charset="utf8" src="http://ajax.aspnetcdn.com/ajax/jquery.dataTables/1.9.1/jquery.dataTables.min.js"></script>
    <script type="text/javascript" charset="utf8">
        $(document).ready(function() {
$('#demo').html( '<table cellpadding="0" cellspacing="0" border="0" class="display" id="example"></table>' );
$('#example').dataTable( {
    "aaData": [
        /* Reduced data set */
         <?= j ?> 

    ],
    "aoColumns": [
        { "sTitle": "Engine" },
        { "sTitle": "Browser" },
        { "sTitle": "Platform" }
    ]
} );   
} );
  </script>
</head>
<body>
<div id="demo"></div>

</body>
</html>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-18T15:02:52+00:00Added an answer on June 18, 2026 at 3:02 pm

    A couple of ideas. Let me know which you prefer/works best. You can write your [1,2,3] as a string and throw that at your template. Like this:

    temp.j = Utilities.jsonStringify([1,2,3]);
    
    <?!= j ?>
    

    Note: the ! is necessary here because it forces the string to be printed as is. See ‘Force-Printing Scriptlets‘.

    Or you can iterate through each element of your data in the html template like this.

    [<? for  (var i = 0; i < j.length; ++i) { ?>
      <?!= j[i]?>,
    <? } ?>]
    

    Note: the square brackets and commas are necessary because j[i] just returns the value of each element.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to use array_filter on an array of objects, and using a public
I am trying to use Jquery to iterate through an array of textboxes where
I'm trying to use jQuery's $getJSON to send an array of 'ids'. Here's what
I'm trying to use the jQuery $.inArray function to iterate through an array and
I'm getting a method or variable not defined when trying to use an array
i am trying to use the YUI to display a table. Using the following
I'm trying to create an associative array with dynamic data, and having some trouble.
I'm trying to use an array to store a list of file names using
I'm having problems trying to use an array of structs which doesn't have an
I'm trying to use an array to set the where parameters for a Zend

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.