on 07-20-2020 9:42 AM
Hi all,
I have a scenario like when we run the application the Messagetoast need to come after that list is loaded the messagetoast need to disappear automatically and without using the time duration. help me on this.
Hi iamcharran83,
Unfortunately, MessageToast cannot be used for that purpose, as we cannot hide MessageToast dynamically. All we can do is to specify duration before showing one.
Instead, I would suggest using a Dialog. You can show a Dialog on binding's dataRequested event, and hide it on dataReceived event.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi iamcharran83,
You can do like below code.
However, loading data usually takes no more than a few seconds, so showing a dialog for such a short amount of time may seem flickering. I would recommend using a busy indicator as boghyon.hoffmann suggested.
Dialog definition (fragment)
<core:FragmentDefinition
xmlns="sap.m"
xmlns:core="sap.ui.core">
<Dialog type="Message" title="Message">
<Text text="Now Loading data..."/>
</Dialog>
</core:FragmentDefinition>
View
<App id="app">
<Table id="table" items="{/Products}">
<!-- ... -->
</Table>
</App><br>
Controller
onInit: function () {
var oTable = this.byId("table");
oTable.getBinding("items").attachDataRequested(this._showDialog, this);
oTable.getBinding("items").attachDataReceived(this._closeDialog, this);
},
_showDialog: function () {
if (!this._oDialog) {
Fragment.load({
name: "demo.dialog.fragment.Dialog",
controller: this
}).then(function (oDialog) {
this._oDialog = oDialog;
this.getView().addDependent(this._oDialog);
this._oDialog.open();
}.bind(this));
} else {
this._oDialog.open();
}
},
_closeDialog: function () {
if (this._oDialog) {
this._oDialog.close();
}
}<br>
Regards,
Mio
User | Count |
---|---|
78 | |
9 | |
8 | |
6 | |
6 | |
6 | |
6 | |
6 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.