关闭后如何清除对话框/xmlfragment 内容?

编程入门 行业动态 更新时间:2024-10-24 18:17:18
本文介绍了关闭后如何清除对话框/xmlfragment 内容?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我的对话被定义为文档:

onOpenDialog : function () { var oView = this.getView(); var oDialog = oView.byId("helloDialog"); // create dialog lazily if (!oDialog) { // create dialog via fragment factory oDialog = sap.ui.xmlfragment(oView.getId(), "sap.ui.demo.wt.view.HelloDialog"); oView.addDependent(oDialog); } oDialog.open(); }

假设这个对话框有很多 Input/Select/ComboBox 等,用户在里面输入,关闭,导航到另一个主条目和详细信息页面,再次打开这个对话框实例,信息仍然在这里.如果我想在每次用户关闭时清除信息/输入怎么办?

Let's say this dialog has many Input/Select/ComboBox and so on, user inputs in it, close, nav to another master item and detail page, open this dialog instance again, and the information is still here. What if I want to clear the information/inputs every time user closes it?

关闭后销毁此对话框是解决此问题的唯一方法吗?

Is destroy this dialog after close the only way to solve this?

推荐答案

Dialog XML

<Dialog afterClose="dialogAfterclose" > <beginButton> <Button text="yes" press="confirmOk"/> </beginButton> <endButton> <Button text="no" press="confirmCancel"/> </endButton> </Dialog>

创建对话框

if(!this._oDialog){ this._oDialog = sap.ui.xmlfragment("idFragment","Path_to_your_Dialog", this); }

你需要使用sap.ui.core.Element的destroy().

dialogAfterclose: function(oEvent) { this._oDialog.destroy(); }

根据您的代码

onOpenDialog : function () { var oView = this.getView(); if (!this._oDialog) { this._oDialog = sap.ui.xmlfragment(oView.getId(), "sap.ui.demo.wt.view.HelloDialog"); oView.addDependent(this._oDialog); } this._oDialog.open(); }, dialogAfterclose: function(oEvent) {//function called after Dialog is closed this._oDialog.destroy();//destroy only the content inside the Dialog }, confirmOk: function(oEvent) { this._oDialog.close();//Just close the Dialog, Dialog afterClose() will be called and destroy the Dialog content. }

参考:sap.ui.core.Element - destroy()

更多推荐

关闭后如何清除对话框/xmlfragment 内容?

本文发布于:2023-11-06 13:33:31,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1563826.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:对话框   内容   xmlfragment

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!