Javascript SAPUI5在控制器中动态创建组合框
目前我正在开发SAPUI5应用程序,在我的页面中。我必须根据来自微服务的数据动态创建组合框 我遵循下面url中的示例代码。 查看来源: 但是,它在我的组合框中返回空 下面是我的示例代码Javascript SAPUI5在控制器中动态创建组合框,javascript,ajax,sapui5,Javascript,Ajax,Sapui5,目前我正在开发SAPUI5应用程序,在我的页面中。我必须根据来自微服务的数据动态创建组合框 我遵循下面url中的示例代码。 查看来源: 但是,它在我的组合框中返回空 下面是我的示例代码 $.ajax({ url: "json/customers.json", dataType: 'json', success: function(response){
$.ajax({
url: "json/customers.json",
dataType: 'json',
success: function(response){
var data= response;
console.log(data);
var customerModel = new JSONModel(data);
console.log(customerModel);
oController.getView().setModel(customerModel, "customerJSON");
var ExtensionForm = oController.getView().byId("Extension_Form");
ExtensionForm.addContent(new sap.m.ComboBox(oController.getView().createId(“ExtensionLabelId”), {
items: {
path: "{ComboBoxModel>/}",
template: new sap.ui.core.Item({
key: "{ComboBoxModel>CUSTOMER_NAME}",
text: "{ComboBoxModel>CUSTOMER_NAME}"
})
},
value : "{model2>/"+ keys[i] + "/fieldvalue}",
enabled: false
}));
},
error: function(error)
{
console.log("Error Message : " + JSON.stringify(error));
}
});
我已经解决了。我只是删除了路径中的花括号{},现在对我来说非常适合 下面是我的代码
$.ajax({
url: "json/customers.json",
dataType: 'json',
success: function(response){
var data= response;
console.log(data);
var customerModel = new JSONModel(data);
console.log(customerModel);
oController.getView().setModel(customerModel, "customerJSON");
var ExtensionForm = oController.getView().byId("Extension_Form");
ExtensionForm.addContent(new sap.m.ComboBox(oController.getView().createId(“ExtensionLabelId”), {
items: {
path: "ComboBoxModel>/",
template: new sap.ui.core.Item({
key: "{ComboBoxModel>CUSTOMER_NAME}",
text: "{ComboBoxModel>CUSTOMER_NAME}"
})
},
value : "{model2>/"+ keys[i] + "/fieldvalue}",
enabled: false
}));
},
error: function(error)
{
console.log("Error Message : " + JSON.stringify(error));
}
});
请分享您的回复数据,我猜您有一个绑定路径问题
路径:“{ComboBoxModel>/}”
@I我已经解决了它。我刚刚删除了{},现在我工作得很好。