Sapui5 将数据绑定到表
如何使用odata模型将数据绑定到?我收到错误,如未找到段“结果”的资源 我的代码:Sapui5 将数据绑定到表,sapui5,sap-fiori,Sapui5,Sap Fiori,如何使用odata模型将数据绑定到?我收到错误,如未找到段“结果”的资源 我的代码: var url = "/sap/opu/odata/sap/ZODATA_SERVICE_NAME"; var oModel = new sap.ui.model.odata.ODataModel(url,false); oModel.read("/EntityDataSet", null, null, true, function(oData) {
var url = "/sap/opu/odata/sap/ZODATA_SERVICE_NAME";
var oModel = new sap.ui.model.odata.ODataModel(url,false);
oModel.read("/EntityDataSet", null, null, true, function(oData) {
that.getView().setModel(oModel,"student");
},
function(error) {
});
<Table headerDesign="Standard"
items="{student>/results}"
id="table" >
<columns>
<Column >
<header>
<Label text="studentName" width="100%"/>
</header>
</Column>
<Column >
<header>
<Label text="studentRank" width="100%"/>
</header>
</Column>
</columns>
<items>
<ColumnListItem >
<cells>
text="{student>StudentName}"/>
text="{student>Rank}"/>
</cells>
</ColumnListItem>
</items>
</Table>
var url=“/sap/opu/odata/sap/ZODATA\u SERVICE\u NAME”;
var oModel=new sap.ui.model.odata.ODataModel(url,false);
读取(“/EntityDataSet”,null,null,true,函数(oData){
setModel(oModel,“student”);
},
函数(错误){
});
text=“{student>StudentName}”/>
text=“{student>Rank}”/>
尝试更改
setModel(oModel,“student”)
到
这个.getView().setModel(oModel,“学生”) that.getView().setModel(oModel,“student”)//不正确
this.getView().setModel(oModel,“student”)//指此特定控制器
SAPUI5单文件模板| nabisoft
sap.ui.getCore().attachInit(函数(){
“严格使用”;
//###控制器###
sap.ui.define([
“sap/ui/core/mvc/Controller”,
“sap/ui/model/odata/v2/ODataModel”
],函数(控制器,ODataModel){
“严格使用”;
返回Controller.extend(“MyController”{
onInit:function(){
//在基于组件的应用程序中,您不会
//甚至需要这段代码:
这是.getView().setModel(
新ODataModel(“https://cors-anywhere.herokuapp.com/services.odata.org/V2/Northwind/Northwind.svc/", {
是的,
useBatch:false
})
);
}
});
});
//###应用程序:将XMLView放在DOM中的某个位置###
sap.ui.xmlview({
viewContent:jQuery(“#myXmlView”).html()
}).placeAt(“内容”);
});