-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsingleui5.html
175 lines (150 loc) · 6.17 KB
/
singleui5.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>SAPUI5 single file template | nabisoft</title>
<!-- decide what version you want to use, see http://scn.sap.com/community/developer-center/front-end/blog/2015/07/30/multi-version-availability-of-sapui5:
<script src="https://sapui5.hana.ondemand.com/resources/sap-ui-core.js"
<script src="https://sapui5.hana.ondemand.com/1.28.28/resources/sap-ui-core.js"
<script src="https://openui5beta.hana.ondemand.com/resources/sap-ui-core.js"
<script src="https://openui5.hana.ondemand.com/resources/sap-ui-core.js"
<script src="https://openui5.hana.ondemand.com/1.36.12/resources/sap-ui-core.js"
-->
<script src="https://openui5.hana.ondemand.com/resources/sap-ui-core.js"
id="sap-ui-bootstrap"
data-sap-ui-theme="sap_bluecrystal"
data-sap-ui-libs="sap.m"
data-sap-ui-bindingSyntax="complex"
data-sap-ui-compatVersion="edge"
data-sap-ui-preload="async"></script>
<!-- use "sync" or change the code below if you have issues -->
<!-- XMLView -->
<script id="myXmlView" type="ui5/xmlview">
<mvc:View
controllerName="MyController"
xmlns="sap.m"
xmlns:f="sap.ui.layout.form"
xmlns:l="sap.ui.layout"
xmlns:core="sap.ui.core"
xmlns:mvc="sap.ui.core.mvc">
<!-- xmlns:nabisoft="nabisoft.ui">
use our custom control, see below
<nabisoft:Headline text="Testing Hana"/>-->
<f:SimpleForm
minWidth="1024"
maxContainerCols="2"
editable="false"
layout="ResponsiveGridLayout"
title="addUser"
labelSpanL="3"
labelSpanM="3"
emptySpanL="4"
emptySpanM="4"
columnsL="1"
columnsM="1">
<f:content>
<Label text="Name" />
<Input id="sName"/>
<Label text="Email" />
<Input id="sEmail"/>
<Label text="Phone" />
<Input id="sPhone"/>
</f:content>
</f:SimpleForm>
<Button id="save" text="Save" type="Emphasized" press="_submitUser" />
<Table
id="myTable"
growing="true"
growingThreshold="10"
growingScrollToLoad="true"
busyIndicatorDelay="0">
<headerToolbar>
<Toolbar>
<Title text="Users"/>
<ToolbarSpacer/>
</Toolbar>
</headerToolbar>
<columns>
<Column>
<Text text="Name"/>
</Column>
<Column>
<Text text="Email"/>
</Column>
<Column>
<Text text="Phone"/>
</Column>
</columns>
<items>
<!-- filled via bindItems() in controller -->
</items>
</Table>
</mvc:View>
</script>
<!-- XML Fragment -->
<script id="myXMLFragment" type="ui5/fragment">
<core:FragmentDefinition
xmlns="sap.m"
xmlns:core="sap.ui.core">
<ColumnListItem type="Active">
<cells>
<ObjectIdentifier title="{NAME}"/>
<Text text="{EMAIL}"/>
<Text text="{PHONE}"/>
</cells>
</ColumnListItem>
</core:FragmentDefinition>
</script>
<script>
sap.ui.getCore().attachInit(function () {
"use strict";
//### Controller ###
sap.ui.define([
"sap/ui/core/mvc/Controller",
"sap/ui/model/odata/v2/ODataModel",
"sap/m/MessageBox"
], function (Controller, ODataModel, MessageBox) {
"use strict";
return Controller.extend("MyController", {
onInit : function () {
this.getView().setModel(
new ODataModel("http://rhxdba01:8000/system-local/public/timmo/timmoSbx/timmoSbx.xsodata/", {
json : true,
useBatch : false
})
);
var sPath = "/User";
var oTable = this.byId("myTable");
var oTemplate = sap.ui.xmlfragment({
fragmentContent : jQuery("#myXMLFragment").html()
});
oTable.bindItems(sPath, oTemplate, null /*oSorter*/, null /*aFilters*/);
},
_submitUser: function() {
var oModel = this.getView().getModel();
var mNewEntry = {};
mNewEntry.NAME = this.byId("sName").getValue();
mNewEntry.EMAIL = this.byId("sEmail").getValue();
mNewEntry.PHONE = this.byId("sPhone").getValue();
oModel.create("/User", mNewEntry, null, function() {
MessageBox.success("User Added Sucessfully");
}, function() {
MessageBox.error("Please Check Record");
});
oModel.refresh();
var oTable = this.byId("myTable");
oTable.getBinding("items").refresh();
}
});
});
//### THE APP: place the XMLView somewhere into DOM ###
sap.ui.xmlview({
viewContent : jQuery("#myXmlView").html()
}).placeAt("content");
});
</script>
</head>
<body class="sapUiBody">
<div id="content"></div>
</body>
</html>