动态将数据源绑定到应用制造商弹出窗口 [英] Dynamically Bind Data source to app maker popup

查看:43
本文介绍了动态将数据源绑定到应用制造商弹出窗口的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要弹出一个通用的删除确认",并使用弹出窗口出现之前触发的事件将数据源动态绑定到弹出窗口.

I need to have a generic "Delete confirmation" pop up and dynamically bind data source to the pop up using event fired before pop-up is appeared.

单击位置"页面上的删除图标将显示弹出窗口(如下所示).我需要同时设置弹出窗口的数据源.(当用户单击此删除图标时),并且必须在用户单击弹出窗口上的删除"按钮时删除记录.

Popup will be appeared on clicking the delete icon on "Location" Page (screenshot bellow). I need to set the data source of the popup at the same time. (when user click on this delete icon) and record has to be deleted when user click on "Delete" button on the popup.

这是我目前用于上方删除图标的onclick事件的代码

This is the code I have currently for the onclick event of the delete icon above

app.popups.ItemDeleteConfirmationDialog.descendants.Content.datasource = widget.datasource;
app.popups.ItemDeleteConfirmationDialog.descendants.ConfirmButton.datasource = widget.datasource;
app.popups.ItemDeleteConfirmationDialog.visible=true;

这就是我在弹出窗口的onClick按钮上所拥有的

And this is what I have for the onClick button of the pop-up

widget.datasource.deleteItem();

请帮助我解决此问题.谢谢.

Please help me to get this resolved. Thank you.

推荐答案

以下是Google App Maker小组的某人的建议:

The following was suggested by someone from the App Maker team at Google:

在确认"弹出窗口中,设置动态类型的自定义属性.在此示例中,调用属性CallbackFn.

In your Confirmation Popup set a custom property of type Dynamic. For the purposes of this example call the property CallbackFn.

对于弹出框中的ConfirmButton的onClick事件,请设置以下客户端脚本:

For the onClick event of your ConfirmButton in the popup set the following client script:

if (typeof widget.root.properties.CallbackFn === 'function') {
  widget.root.properties.CallbackFn();
}
widget.root.visible = false;

为数据源表中的删除按钮设置以下客户端脚本:

For the delete button in your datasource table set the following client script:

deleteItem(widget.datasource);

在脚本"部分中,添加客户端脚本或在现有客户端脚本下插入以下功能:

In your scripts section add a client script or insert the following function under an existing client script:

function deleteItem(datasource) {
  var popup = app.popups.ItemDeleteConfirmationDialog;

  popup.properties.CallbackFn = function() {
    datasource.deleteItem();
  };

  popup.visible = true;
}

由于表中的删除按钮位于表行内,因此您可能需要更改传递给deleteItem()函数的函数变量,如下所示:

Since your delete button in your table is within a table row, you may need to change the function variable that you pass to the deleteItem() function as follows:

deleteItem(widget.parent.parent.datasource);

如果这不起作用,请告诉我.我已经在自己的应用程序中使用了更为复杂的逻辑进行了此设置,并且在某些情况下将多个变量传递给了deleteItem()函数,并且效果很好.

If this doesn't work let me know. I have this set up in my own application with much more complex logic and I pass multiple variables in some cases to my deleteItem() function and it works great.

这篇关于动态将数据源绑定到应用制造商弹出窗口的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆