on 2023 Jan 18 6:16 AM
Hi All,
I have created a custom UI5 app. In View1, I have used sap.m.table for user input. The table is initially blank, where user can add/ delete rows. After saving the data of the table, I am navigating to View2. But when I come back to View1, the data entered by the user is still there, and not getting refreshed. I have tried the following syntax, but it doesn’t help. I'm saving, adding, deleting, and changing data on the back end, but the UI screen doesn't seem to be cleared/ refreshed. Please advise.
onInit: function () {
this.oScopeTable = this.getView().byId("idtable_newDeal");
var TableModel = new sap.ui.model.json.JSONModel([]);
this.getView().setModel(TableModel, "tableModel");
this.onAddRow();
}
onAddRow: function (oEvent) {
var tableModel = this.getView().getModel("tableModel");
tableModel.getData().push({});
tableModel.refresh();
},
onRefresh: function () {
// this.getView().getModel("tableModel").setData({
// tableModel: {}
// });
// this.getView().getModel("tableModel").refresh(true);
// this.oScopeTable.getModel().refresh(true) ;
// this.oScopeTable.getBinding("rows").refresh();
// this.oScopeTable.getBinding("items").refresh();
}
var tableModel = this.getView().getModel("tableModel");
tableModel.setData([])
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
HI,
maybe you can try following code for refresh data in table:
tableModel.updateBindings(true);
Best Regards
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
where do you save the data to the backend? I only see logic storing it in a json model…
not makes sense that it is not cleared when you come back to view 1. The onInit function is only called the very first time. Afterwards you need to use routing and an route matched eventhandler, see example:
https://ui5.sap.com/#/topic/516e477e7e0b4e188b19a406e7528c1e
sap.ui.require([
"sap/ui/core/mvc/Controller",
"sap/ui/core/UIComponent", ...
], function(UIComponent, ...) {
"use strict";
return Controller.extend("MyApp.View1", {
onInit: function() {
var oRouter = this.getOwnerComponent().getRouter();
oRouter.getRoute("view1").attachMatched(function(oEvent) {
this._selectItemWithId(oEvent.getParameter("arguments").id);
}, this);
},
_selectItemWithId : function(id) {
//implementation
}
});
});
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
71 | |
10 | |
8 | |
7 | |
6 | |
6 | |
6 | |
6 | |
6 | |
5 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.