on 2019 Sep 20 10:59 AM
Hi All,
I am working on SAPUI5 Application development. In my app i am using, sap.ui.table. From OData service, i got an collection, which i consumed, and set an local json model for my further need. I bounded the local json into sapui5 table, i able to see the data.
Later as per my app scenario, i need to add more data into the table row(via button on the table tool bar).once i added the, new rows into the table, i have a save button at the top which should update the latest added entries to the OData Collection, and my table also should be refreshed.
I have a question:
1. How to add the new records with the existing collection(json), in the table?
2. once i added, i called the create entityset. how to update the local json model and table bindings?
Thank you,
Regards,
JK.
Hi jayakrishnan.chnadramohan ,
this is my code for adding the simple row of one table with json local model:
addToTable : function (oData) {
//oData is new object
var updateElementPath = this.getView().getModel().createKey(path, {
"country": oData.country,
"brand": oData.brand
});
var promiseNewCountryBrand = new Promise(function (resolve, reject) {
sap.ui.core.BusyIndicator.show(0);
this.getModel().update(updateElementPath, oData, {
success: function () {
resolve();
},
error: function (msg) {
reject();
}
});
}.bind(this));
promiseNewCountryBrand.then(function () {
//here i added the new object in BE system
// now I'm adding to table (json model)
MessageToast.show("Update Correctly");
sap.ui.core.BusyIndicator.hide();
var oDataTotal = this._countriesModel.getData(); //json Model
oDataTotal.countryList.unshift(oData);
var oDataTotalNew = jQuery.extend(true, {}, oDataTotal);
oDataTotal.countryList = [];
this._countriesModel.setData(oDataTotal);
this._countriesModel.refresh(true);
//timeout is for sync calling (i know maybe is useless but work)
setTimeout(function () {
this._countriesModel.setData(oDataTotalNew);
setTimeout(function () {
this._countriesModel.refresh(true);
}.bind(this), 150);
}.bind(this), 150);
}.bind(this)).catch(function (aError) {
sap.ui.core.BusyIndicator.hide();
});
};
Ask me if you don't understand . 🙂
Sebastiano
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thanks Sebastiano Marchesini, I will look at this.
User | Count |
---|---|
57 | |
10 | |
7 | |
7 | |
6 | |
6 | |
5 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.