App maker: Show Big Query data in grid

2019-08-21 04:07发布

问题:

I having an script in googles app maker:

    function runQuery() {
  var projectId = 'blalab155512';
  var request = {
    query: 'SELECT title FROM [bigquery-public-data:samples.wikipedia]  where title contains "olimpic" LIMIT 100'
  };
  var queryResults = BigQuery.Jobs.query(request, projectId);
  var jobId = queryResults.jobReference.jobId;
  var names = queryResults.schema.fields.map(function(field){ return field.name; });


  //var records = [];  
  return queryResults.rows.map(function(row) {
  var record = app.models.Test.newRecord();
  for (var i = 0, len = names.length; i < len; ++i) {
    // Calculated model should contain correspondent fields
    // all non-defined fields will be ignored
    record[names[i]] =  (row.f[i].v);
  }

  return record;
});
}

Which gives me the desired data from Big Query. Data format output from Logger:

I'm now struggling with put that data as an Calculated Data Source and then show it as a grid within the app.

I have a calculated data source, which calls the script above to get the data. And I configured a field (String) in which I want to out the titles from the query.

In preview no error was shown but the grid stay empty:

回答1:

Unlike Table widget, Grid widget will not generate all nested data-bound widgets for you. You need to manually add, layout and bind all display widgets: