globalThis.onUI5Init = () => sap.ui.require([
"sap/ui/core/Fragment",
"sap/ui/model/odata/v4/ODataModel",
"sap/ui/core/Core",
], async (Fragment, ODataModel, Core) => {
"use strict";
const definition = document.getElementById("myxmlfragment").textContent;
const control = await Fragment.load({ definition });
control.setModel(new ODataModel({
serviceUrl: "https://services.odata.org/TripPinRESTierService/(S(myservice))/",
synchronizationMode: "None",
operationMode: "Server",
groupId: "$direct",
})).placeAt("content");
Core.getMessageManager().registerObject(control, true);
});
<script defer id="sap-ui-bootstrap"
src="https://openui5.hana.ondemand.com/resources/sap-ui-core.js"
data-sap-ui-libs="sap.ui.core,sap.m,sap.ui.unified"
data-sap-ui-oninit="onUI5Init"
data-sap-ui-theme="sap_fiori_3"
data-sap-ui-async="true"
data-sap-ui-compatversion="edge"
data-sap-ui-excludejquerycompat="true"
data-sap-ui-xx-waitfortheme="init"
></script>
<script id="myxmlfragment" type="text/xml">
<VBox xmlns="sap.m"
class="sapUiTinyMargin"
xmlns:core="sap.ui.core"
renderType="Bare"
binding="{/People('russellwhyte')/Trips(0)}"
>
<DateRangeSelection
core:require="{
DateTimeOffset: 'sap/ui/model/odata/type/DateTimeOffset',
DateInterval: 'sap/ui/model/type/DateInterval'
}"
placeholder="<From> - <To>"
width="16rem"
value="{
parts: [
{
path: 'StartsAt',
type: 'DateTimeOffset',
formatOptions: { UTC: true }
},
{
path: 'EndsAt',
type: 'DateTimeOffset',
formatOptions: { UTC: true }
}
],
type: 'DateInterval',
formatOptions: { UTC: true },
parameters: { $$noPatch: true }
}"
/>
<!-- To display values stored in the model: -->
<ObjectStatus
title="StartsAt value"
text="{ path: 'StartsAt', targetType: 'any' }"
/>
<ObjectStatus
title="EndsAt value"
text="{ path: 'EndsAt', targetType: 'any' }"
/>
</VBox>
</script>
<body id="content" class="sapUiBody sapUiSizeCompact"></body>