我已经开始学习SAP ui5。我按照教程创建表,这是我所拥有的。
index.html:
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta http-equiv='Content-Type' content='text/html;charset=UTF-8'/>
<script src="resources/sap-ui-core.js"
id="sap-ui-bootstrap"
data-sap-ui-libs="sap.ui.commons, sap.m, sap.ui.table, sap.ui.model, sap.ui.model.json"
data-sap-ui-theme="sap_bluecrystal">
</script>
<!-- add sap.ui.table,sap.ui.ux3 and/or other libraries to 'data-sap-ui-libs' if required -->
<script src="app/data.js"></script>
<script src="app/app.js"></script>
</head>
<body class="sapUiBody" role="application">
<div id="content"></div>
</body>
</html>
app.js
var oTable = new sap.ui.table.Table({
title: "My first table",
visibleRowCount: 5,
firstVisibleRow: 2,
selectionMode: sap.ui.table.SelectionMode.Single,
toolbar: new sap.ui.commons.Toolbar({
items: [
new sap.ui.commons.Button({
text: "Toolbar button",
press: function() {
alert("Toolbar button pressed");
}
})
]
}),
extenstion: [
new sap.ui.commons.Button( {
text: "Extenstion button",
press: function() {
alert("Extenstion button pressed");
}
})
]
});
oColumn = new sap.ui.table.Column({
label: new sap.ui.commons.Label({
text: "Last name"
}),
template: new sap.ui.commons.TextView().bindProperty("text", "lastName"),
sortProperty: "lastName",
filterProperty: "lastName",
width: "200px"
});
var oCustomMenu = new sap.ui.commons.Menu();
oCustomMenu.addItem(new sap.ui.commons.MenuItem({
text: "Custom Menu",
select: function() {
alert("Custom menu");
}
}));
oColumn.setMenu(oCustomMenu);
oTable.addColumn(oColumn);
oTable.addColumn(new sap.ui.table.Column({
label: new sap.ui.commons.Label({
text: "ID"
}),
template: new sap.ui.commons.TextField().bindProperty("value", "firstName"),
sortProperty: "name",
filterProperty: "name",
width: "100px"
}));
oTable.addColumn(new sap.ui.table.Column({
label: new sap.ui.commons.Label({
text: "First name"
}),
template: new sap.ui.commons.TextField().bindProperty("value", "firstName"),
sortProperty: "name",
filterProperty: "name",
width: "100px"
}));
oTable.addColumn(new sap.ui.table.Column({
label: new sap.ui.commons.Label({
text: "First name"
}),
template: new sap.ui.commons.TextField().bindProperty("value", "firstName"),
sortProperty: "name",
filterProperty: "name",
width: "100px"
}));
var oModel = new sap.ui.model.json.JSONModel();
oModel.setData({
modelData: data
});
oTable.sort(oTable.getColumns()[0]);
oTable.placeAt("content");
data.js:
var data = [
{firstName: "Michal", lastName: "Kohut", id: 358, phone: 4584250, rating: 5},
{firstName: "Jan", lastName: "Pribrzdený", id: 157, phone: 1325124, rating: 1},
{firstName: "Milena", lastName: "Dnesmameninova", id: 874, phone: 3698548, rating: 4}
]
我正在使用sapui5插件在Eclipse中进行此操作。当我运行时,出现以下错误:
我真的是javascript和sapui5的新手。你能帮我弄清楚吗?
最佳答案
在index.html的sap.ui.model
声明中,不需要sap.ui.model.json
和data-sap-ui-libs
。删除语句中的两个库。
尝试使用:
<script src="resources/sap-ui-core.js"
id="sap-ui-bootstrap"
data-sap-ui-libs="sap.ui.commons, sap.m, sap.ui.table"
data-sap-ui-theme="sap_bluecrystal">
</script>
关于javascript - SapUI5表-找不到404错误,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/29537555/