如何在SAPUI5中绑定表单?
我试图找出如何在UI5中绑定一个简单的表单(不是列表),这样我就可以提交到我的oData后端。我如何用一个简单的表单来实现这一点 这是我的控制器代码(如果我在列表中执行),但我不知道如何处理表单:如何在SAPUI5中绑定表单?,sapui5,Sapui5,我试图找出如何在UI5中绑定一个简单的表单(不是列表),这样我就可以提交到我的oData后端。我如何用一个简单的表单来实现这一点 这是我的控制器代码(如果我在列表中执行),但我不知道如何处理表单: var oList = this.byId("addapp"), oBinding = oList.getBinding("items"), // Create a new entry through the table's list b
var oList = this.byId("addapp"),
oBinding = oList.getBinding("items"),
// Create a new entry through the table's list binding
oContext = oBinding.create({
"application_id": 0,
"product_name_short": 'Test',
});
这是我迄今为止尝试过的,但我得到了未定义的值:
var x =this.getView().byId("addapp").getBinding("items");
如果已将模型设置为视图,则可以使用以下方法将现有对象绑定到视图: 如果要使用临时模型(单击“添加”或类似操作后使用数据):
this.getView().byId("addapp").bindElement("/path/to/your/object");
onInit: function () {
// Initial values of the form
this.getView().setModel(new sap.ui.model.json.JSONModel({
property1: "",
property2: "",
property3: ""
}), "newEntry");
// Bind the form to the json model
this.getView().byId("addapp").bindElement("newEntry>/");
},
onAddButtonClick: function() {
// Get the form values
var newEntry = this.getView().getModel("newEntry").getData();
// Use the OData model to create a new entity
var oDataModel = ...;
oDataModel.create("/path/to/your/entityset", newEntry, {
success: function() {
// entity was created
}
});
}