"sap/m/ColumnListItem",
"sap/m/Input"
function (Controller, MessageToast,ColumnListItem,Input)
this.oEditableTemplate = new ColumnListItem({
cells: [
new Input({
value: "{mainModel>soNumber}",
change: [this.onInputChange, this]
}), new Input({
value: "{mainModel>customerName}",
change: [this.onInputChange, this]
}), new Input({
value: "{mainModel>customerNumber}",
change: [this.onInputChange, this]
}), new Input({
value: "{mainModel>PoNumber}",
change: [this.onInputChange, this]
}), new Input({
value: "{mainModel>inquiryNumber}",
change: [this.onInputChange, this]
})
]
});
rebindTable: function(oTemplate, sKeyboardMode) {
this._oTable.bindItems({
path: "mainModel>/SalesOrder",
template: oTemplate,
templateShareable: true
}).setKeyboardMode(sKeyboardMode);
},
this.rebindTable(this.oEditableTemplate, "Edit");
this.oEditableTemplate = new ColumnListItem({
cells: [
new Input({
value: "{mainModel>soNumber}",
change: [this.onInputChange, this]
}), new Input({
value: "{mainModel>customerName}",
change: [this.onInputChange, this]
}), new Input({
value: "{mainModel>customerNumber}",
change: [this.onInputChange, this]
}), new Input({
value: "{mainModel>PoNumber}",
change: [this.onInputChange, this]
}), new Input({
value: "{mainModel>inquiryNumber}",
change: [this.onInputChange, this]
})
]
});
onInputChange: function(){
this.refreshModel("mainModel");
},
refreshModel: function (sModelName, sGroup){
return new Promise((resolve,reject)=>{
this.makeChangesAndSubmit.call(this,resolve,reject,
sModelName,sGroup);
});
},
makeChangesAndSubmit: function (resolve, reject, sModelName,sGroup){
const that = this;
sModelName = "mainModel";
sGroup = "$auto";
if (that.getView().getModel(sModelName).hasPendingChanges(sGroup)) {
that.getView().getModel(sModelName).submitBatch(sGroup).then(oSuccess =>{
that.makeChangesAndSubmit(resolve,reject, sModelName,sGroup);
MessageToast.show("Record updated Successfully");
},reject)
.catch(function errorHandler(err) {
MessageToast.show("Something Went Wrong ",err.message); // 'Oops!'
});
} else {
that.getView().getModel(sModelName).refresh(sGroup);
resolve();
}
},
onSave: function(){
this.getView().byId("editModeButton").setVisible(true);
this.getView().byId("saveButton").setVisible(false);
this._oTable.setMode(sap.m.ListMode.None);
this.rebindTable(this.oReadOnlyTemplate, "Navigation");
},
_createReadOnlyTemplates: function () {
this.oReadOnlyTemplate = new sap.m.ColumnListItem({
cells: [
new sap.m.Text({
text: "{mainModel>soNumber}"
}),
new sap.m.Text({
text: "{mainModel>customerName}"
}),
new sap.m.Text({
text: "{mainModel>customerNumber}"
}),
new sap.m.Text({
text: "{mainModel>PoNumber}"
}),
new sap.m.Text({
text: "{mainModel>inquiryNumber}"
})
]
});
},
this._createReadOnlyTemplates();
this.rebindTable(this.oReadOnlyTemplate, "Navigation");
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
7 | |
5 | |
5 | |
4 | |
4 | |
4 | |
4 | |
4 | |
3 | |
3 |