应用制作工具删除 table 上的项目并更新
App Maker delete items on table and update
我有一个应用程序,我希望能够从 google 电子表格中获取列并在我的应用程序中的 table 上创建一个列表。我也希望能够从此 table.
中删除项目
截至目前,我正在使用 AMU 库函数 AMU.deleteAll
,它所做的只是
AMU.deleteAll = function(widget){
var records = widget.datasource.items;
records.forEach(function(record){
record._delete();
});
};
所以当我有一个全新的空白 table 时,我的应用可以在我使用 AMU.import.fromSpreadsheet
时从我的电子表格更新(在此处查看完整库 goo。gl/RkeqZw) 它将从我的电子表格中取出所有项目并将它们正确放置在我的 table 中,之后我可以使用删除功能删除我的 table 中的所有项目。这是事情变得一团糟的地方,当我再次尝试使用导入功能时,列表中填充了空条目,如果我尝试使用删除功能,我会收到错误消息:
"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)"
我不确定为什么会这样,对我来说似乎正在保存数据并且删除功能只删除值,而不是实际条目。
如果您想从您的模型中删除所有项目,您可以进行单个服务器调用(您上面引用的代码会切断对客户端加载的每个单独项目的调用):
// 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();
我有一个应用程序,我希望能够从 google 电子表格中获取列并在我的应用程序中的 table 上创建一个列表。我也希望能够从此 table.
中删除项目截至目前,我正在使用 AMU 库函数 AMU.deleteAll
,它所做的只是
AMU.deleteAll = function(widget){
var records = widget.datasource.items;
records.forEach(function(record){
record._delete();
});
};
所以当我有一个全新的空白 table 时,我的应用可以在我使用 AMU.import.fromSpreadsheet
时从我的电子表格更新(在此处查看完整库 goo。gl/RkeqZw) 它将从我的电子表格中取出所有项目并将它们正确放置在我的 table 中,之后我可以使用删除功能删除我的 table 中的所有项目。这是事情变得一团糟的地方,当我再次尝试使用导入功能时,列表中填充了空条目,如果我尝试使用删除功能,我会收到错误消息:
"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)"
我不确定为什么会这样,对我来说似乎正在保存数据并且删除功能只删除值,而不是实际条目。
如果您想从您的模型中删除所有项目,您可以进行单个服务器调用(您上面引用的代码会切断对客户端加载的每个单独项目的调用):
// 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();