<mvc:View controllerName="practise.Data_AutoFill.controller.View1" xmlns:l="sap.ui.layout" xmlns:f="sap.ui.layout.form"
xmlns:mvc="sap.ui.core.mvc" xmlns:core="sap.ui.core" xmlns="sap.m">
<VBox class="sapUiSmallMargin" alignItems="Center" justifyContent="Center">
<f:SimpleForm editable="true" layout="ResponsiveGridLayout" labelSpanXL="4" labelSpanL="3" labelSpanM="4" labelSpanS="12"
adjustLabelSpan="false" emptySpanXL="0" emptySpanL="4" emptySpanM="0" emptySpanS="0" columnsXL="2" columnsL="1" columnsM="1"
singleContainerFullSize="false" ariaLabelledBy="Title1">
<f:toolbar>
<Toolbar>
<ToolbarSpacer/>
<Title text="{i18n>title}" level="H4" titleStyle="H4"/>
<ToolbarSpacer/>
<Button icon="sap-icon://journey-change" press="onFill"/>
</Toolbar>
</f:toolbar>
<f:content>
<Label text="Postal Code" design="Bold"/>
<Text text="{oModel>/0/ShipPostalCode}"/>
<Label text="Customer ID" design="Bold"/>
<Text text="{oModel>/0/CustomerID}"/>
<Label text="Address" design="Bold"/>
<Text text="{oModel>/0/ShipAddress}"/>
<Label text="Country" design="Bold"/>
<Text text="{oModel>/0/ShipCountry}"/>
<Label text="Freight" design="Bold"/>
<Text text="{oModel>/0/Freight}"/>
<Label text="City" design="Bold"/>
<Text text="{oModel>/0/ShipCity}"/>
</f:content>
</f:SimpleForm>
</VBox>
</mvc:View>
sap.ui.define([
"sap/ui/core/mvc/Controller",
"sap/ui/model/json/JSONModel"
], function (Controller, JSONModel) {
"use strict";
return Controller.extend("practise.Data_AutoFill.controller.View1", {
onInit: function () {
this.onFill();
this.serviceCall();
},
onFill: function () {
if (!this._fillDialog) {
this._fillDialog = sap.ui.xmlfragment("practise.Data_AutoFill.Fragment.DataFill", this);
this.getView().addDependent(this._fillDialog);
}
this._fillDialog.open();
},
serviceCall: function () {
var that = this;
this.getOwnerComponent().getModel().read("/Orders", {
urlParameters: {
$expand: "Order_Details"
},
success: function (oData, oResponse) {
var oModel_order = new JSONModel();
oModel_order.setData(oData);
that.getView().setModel(oModel_order, "oModel_order");
that.getView().getModel("oModel_order").refresh();
}
});
},
onChange: function (oEvent) {
var orderID = oEvent.getParameter("value");
var oModelData = this.getView().getModel("oModel_order").getData().results;
var itemDetails = [];
for (var i = 0; i < oModelData.length; i++) {
if (orderID === oModelData[i].OrderID.toString()) {
itemDetails.push(oModelData[i]);
}
}
var oModel = new JSONModel();
oModel.setData(itemDetails);
this.getView().setModel(oModel, "oModel");
this.getView().getModel("oModel").refresh();
this.onCancelPress();
},
onCancelPress: function () {
this._fillDialog.close();
}
});
});
<core:FragmentDefinition xmlns:f="sap.ui.layout.form" xmlns:cm="sap.ui.commons" xmlns:l="sap.ui.layout" xmlns:core="sap.ui.core"
xmlns="sap.m">
<Dialog class="sapUiNoContentPadding sapUiSizeCompact" stretchOnPhone="true" showHeader="false" contentWidth="auto" resizable="true"
type="Standard">
<subHeader>
<Bar>
<contentMiddle>
<Label text="Basic Info" design="Bold" class="MasterData_Title"/>
</contentMiddle>
</Bar>
</subHeader>
<content>
<f:SimpleForm editable="false" layout="ResponsiveGridLayout" labelSpanXL="3" labelSpanL="3" labelSpanM="3" labelSpanS="12"
adjustLabelSpan="false" emptySpanXL="4" emptySpanL="4" emptySpanM="4" emptySpanS="0" columnsXL="1" columnsL="1" columnsM="1"
singleContainerFullSize="false">
<f:content>
<Label text="Order ID" design="Bold"/>
<ComboBox width="100%" items="{path:'oModel_order>/results'}" id="itemId" change="onChange">
<core:Item key="{oModel_order>OrderID}" text="{oModel_order>OrderID}"/>
</ComboBox>
<Label text="Customer ID" design="Bold"/>
<Text text="{oModel>/0/CustomerID}"/>
</f:content>
</f:SimpleForm>
</content>
</Dialog>
</core:FragmentDefinition>
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
6 | |
4 | |
4 | |
4 | |
4 | |
3 | |
3 | |
3 | |
3 | |
3 |