Export filtered data from table widget Google AppM

2019-09-21 19:07发布

Does anyone know how we can export filtered data from Google App Maker table widget.

My table from the data source (no filter): that show everything

After applying some filter filtered.

I manage to export everything to Google Spreadsheet (see this SO answer), but I am stuck on exporting only the data after applying some filter. Really appreciate if anyone can share the solution. Thanks!

2条回答
三岁会撩人
2楼-- · 2019-09-21 19:37

The AMU Library can do this in one command in a button onClick. The button just needs to be on the same datasource as the table.

Simply:

AMU.export.toSpreadsheet = function(widget, Your_modelName);
查看更多
我想做一个坏孩纸
3楼-- · 2019-09-21 20:01

It seems that you are looking for filters. It should work if you modify script from this answer to something similar to this:

// Server script
function dataExport(filter1, filter2, ...) {
  // TODO: Check permissions.
  ...
  var query = app.models.MyModel.newQuery();

  // TODO: Apply user/roles specific filters for
  // security reasons.
  query.filters.Field1._equals = filter1;
  query.filters.Field2._greaterThan = filter2;
  ...
  var filteredRecords = query.run();

  filteredRecords.forEach(function(record) {
    ...
  });
  ...
查看更多
登录 后发表回答