Sapui5 列表未绑定
我无法将数据绑定到列表。尝试了两种方法-在视图中直接绑定,在控制器的onInit方法中也使用read方法。 请帮忙 查看代码:Sapui5 列表未绑定,sapui5,Sapui5,我无法将数据绑定到列表。尝试了两种方法-在视图中直接绑定,在控制器的onInit方法中也使用read方法。 请帮忙 查看代码: var oList = new sap.m.List({ type:sap.m.ListType.Navigation, id : this.createId("qList"), template: listItems }); var listItems = new sap.m.ActionListIt
var oList = new sap.m.List({
type:sap.m.ListType.Navigation,
id : this.createId("qList"),
template: listItems
});
var listItems = new sap.m.ActionListItem({
text:"{Quarter}",
id : this.createId("Q1"),
type:sap.m.ListType.Navigation,
press:function(){
oController.quarterSelect();
}});
oList.bindItems("fullmodel>/ETQUARTERSet", listItems);
控制器代码:
onInit: function() {
this.router = sap.ui.core.UIComponent.getRouterFor(this);
var oModel = new sap.ui.model.odata.ODataModel("http://dewdfcto021.wdf.sap.corp:1080/sap/opu/odata/SAP/ZOC_SERVICES_SRV/");
sap.ui.getCore().setModel(oModel,"fullmodel");
var quartersList = this.byId("qList");
var quarterItem = this.byId("Q1");
var pathFilterCond = "/ETQUARTERSet";
oModel.read(pathFilterCond, null, null, true, function(oData, oResponse)
{
if (oData)
{
var oJSONQuarters = new sap.ui.model.json.JSONModel(oData);
quartersList.setModel(oJSONQuarters);
quartersList.bindAggregation("items", "/Quarter", quarterItem);
}
}
);
},
请记住,在使用命名模型时,每个绑定路径中都应以该模型的名称为前缀。绑定listItem的文本时丢失了模型名称
var listItems = new sap.m.ActionListItem({
text:"{fullmodel>Quarter}",
id : this.createId("Q1"),
type:sap.m.ListType.Navigation,
press:function(){
oController.quarterSelect();
}});
oList.bindItems(“fullmodel>/ETQUARTERSet”,listItems)