简体   繁体   English

App Maker删除表格上的项目并更新

[英]App Maker delete items on table and update

I have an app that I would like to be able to take columns from a google spreadsheet and make a list on a table in my app. 我有一个应用程序,希望能够从Google电子表格中获取列并在应用程序中的表格上列出清单。 Also I would like to be able to remove items from this table. 我也希望能够从该表中删除项目。

As of now I am using the AMU library function AMU.deleteAll , all it does is 到目前为止,我正在使用AMU库函数AMU.deleteAll ,它所做的就是

AMU.deleteAll = function(widget){
  var records = widget.datasource.items;
  records.forEach(function(record){
   record._delete();
  });  
};

So what happens is that when I have a completely new and blank table my app can update from my spreadsheet when I use AMU.import.fromSpreadsheet (check here for full library goo.gl/RkeqZw) it will take all the items from my spreadsheet and place them properly in my table, after that I can use the delete function to remove all items on my table. 所以发生的事情是,当我有一个全新的空白表时,当我使用AMU.import.fromSpreadsheet (在此处查看完整的库goo.gl/RkeqZw)时,我的应用可以从电子表格中进行更新,它将从我的电子表格中获取所有项目并将它们正确放置在我的桌子上,之后,我可以使用删除功能删除桌子上的所有项目。 Here is where things get all screwy, when I try to use the import function again the list gets populated with empty entries and if I try to use the delete function I get an error: 这是所有事情的棘手问题,当我再次尝试使用导入功能时,列表中填充了空条目,如果尝试使用删除功能,则会出现错误:

"Drive Table internal error. Record not found. Caused by: Execution Failed. More information: Object not found at path: camo0A_084fQ. (HTTP status code: 404) Error: Drive Table internal error. Record not found. at deleteAllData (ServerScript:232)" “驱动器表内部错误。找不到记录。由以下原因导致:执行失败。更多信息:在路径:camo0A_084fQ上找不到对象。(HTTP状态代码:404)错误:驱动器表内部错误。找不到记录。在deleteAllData(服务器脚本: 232)”

I am not sure why this is happening, to me it seems like the data is being saved and the delete function only removes the value, and not the actual entry. 我不确定为什么会发生这种情况,对我来说似乎是在保存数据,而删除功能只会删除值,而不是实际的条目。

If you want to delete all items from your model you can make single server call (the code you quoted above does sever call for each individual item loaded on client): 如果要从模型中删除所有项目,则可以进行一次服务器调用(上面引用的代码会严重调用客户端上加载的每个项目):

// server script to delete all records from model
function deleteAllRecordsFromModel() {
  var allRecords = app.models.MyModel.newQuery().run();
  app.deleteRecords(allRecords);
}

// client script to call server function
google.script.run
  .withSuccessHandler(function() {
     // TODO: Handle success (optional)
  })
  .withFailureHandler(function() {
     // TODO: Handle error (optional)
  })
  .deleteAllRecordsFromModel();

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM