我正在寻求你的帮助。我创建了一个网络应用程序。在这里我可以创建一个表和控制条目。现在我很沮丧,因为我不知道如何将这个表保存到数据库中。这是保存功能:
onSave: function() {
//Create all the records added to table via Json model
var oTable = this.getView().byId("packItem");
// Get the table Model
var oModel = oTable.getModel();
// Get Items of the Table
var aItems = oTable.getItems();
// Define an empty Array
var itemData = [];
for (var iRowIndex = 0; iRowIndex < aItems.length; iRowIndex++) {
var l_material = oModel.getProperty("Material", aItems[iRowIndex].getBindingContext());
var l_batch = oModel.getProperty("Batch", aItems[iRowIndex].getBindingContext());
var l_quantity = oModel.getProperty("Quantity", aItems[iRowIndex].getBindingContext());
var l_unit = oModel.getProperty("Unit", aItems[iRowIndex].getBindingContext());
itemData.push({
Batch: l_batch,
Matnr: l_material,
Qty: l_quantity,
Uom: l_unit,
});
}
// Get the values of the header input fields
var ComCode = this.getView().byId("inputCC").getValue();
var Plant = this.getView().byId("inputPlant").getValue();
// Create one emtpy Object
var oEntry1 = {};
oEntry1.Bukrs = ComCode;
oEntry1.Werks = Plant;
var oModel1 = new sap.ui.model.odata.ODataModel(""); // Define the model
this.getView().setModel(oModel1);// set the model
oModel1.setHeaders({"X-Requested-With": "X"});
oModel1.create("", oEntry1, { // Call the OData Service (.creat Function)
success: function(oData, oResponse) {
},
error: function(oError) {
alert("Failure - OData Service could not be called. Please check the Network Tab at Debug.");
}
});
}