Details of Control Type Supported in the control
Note:- Also Provide a custom annotation sap:display-format="Date"
Time Picker
Note:- Do not provide sap:display-format="Date" annotation
Note:- Do not provide sap:display-format="Date" annotation
Field Control
Note: Later will take preference over the former in case of conflict.
Note: Later will take preference over the former in case of conflict.
Validations & Checks
Properties available in this control
Name | Type | Default Value | Description |
entityTypeName | string | Specifies Name of the OData entity | |
title | string | null | Title of the form |
mode | string | null | Specifies mode in which control needs to be Rendered. "E" for Edit mode and "D" for display Mode |
includeOnlyFields | string[] | [] | Specifies Explicit list of fields to display. All other fields will be ignored. Example of Usage <Form includeOnlyFields="F1,F2,F3" /> |
useSplitLayout | boolean | true | Specifies whether to use split form layout (with two form containers) |
required | boolean | false | If set to true then all the fields in the Form becomes mandatory |
odataModelName | string | Specifies name of the OData Model. Note:- Use this property only when odata model has some name | |
dataPath | string | Specifies the path in the binded model(Name of the model is stored in the property modelName) where Form data is stored | |
modelName | string | Name of the Binded Model where data of the Form is stored | |
mandatoryFields | string[] | [] | Specifies name of the field which have to be marked as mandatory and those are not configurable by the user. Example of Usage <Form mandatoryFields="F1,F2,F3" /> |
propertyMap | object | Using this property a user can handle:- 1. Custom Behavior of default types* Using the user can override the the default behavior of the control type and provide their own custom behavior. 2. Custom Control type factory** Using this user can even user their own control factory if the default one does not suites to their requirement. |
{
LifeCycleStatus:{
enabled: // Handling of enable property
}
}
{
CreatedByBp: {
editFactory: // bind method name which returns checkBox control factroy which // will be rendered in edit mode,
displayFactory: // bind method name which returns checkBox control factroy // which will be rendered in display mode
}
}
Param | Type | Description |
oControlEvent | sap.ui.base.Event | |
getSource | sap.ui.base.EventProvider | |
getParameters | object | |
event | sap.ui.base.Event | event of the control which is fired by particular form fied |
field | string | The name of an updated field |
value | string | New field value |
entityType | string | Name in the Entity type passed in the property entityTypeName |
Soheaderdata Entity
<mvc:View controllerName="sa.sap.sample.reuse.form.controller.SalesOrder"
xmlns:html="http://www.w3.org/1999/xhtml"
xmlns:mvc="sap.ui.core.mvc"
displayBlock="true"
xmlns="sap.m"
xmlns:c="sap.custom.controls.form">
<App id="idAppControl">
<pages>
<Page title="Custom Form Sample">
<content>
<c:Form id="idSalesOrderDetails"
entityTypeName="Soheaderdata"
title="Sales Order Details"
editable="true"
visible="true"
mode="{FormDataModel>/displayMode}"
modelName="FormDataModel"
dataPath="/data" />
</content>
<footer>
<Bar>
<contentRight>
<Button text="Save" visible="{=${FormDataModel>/displayMode} !== 'D'}" press="onSalesOrderSave" />
<Button text="Edit" visible="{=${FormDataModel>/displayMode} === 'D'}" press="onSalesOrderEdit" />
<Button text="Display" visible="{=${FormDataModel>/displayMode} !== 'D'}" press="onSalesOrderDisplay"/>
</contentRight>
</Bar>
</footer>
</Page>
</pages>
</App>
</mvc:View>
Control declaration
sap.ui.define([
"sap/ui/core/mvc/Controller",
"sap/ui/model/json/JSONModel",
"sap/m/MessageToast"
], function (Controller, JSONModel, MessageToast) {
"use strict";
return Controller.extend("sa.sap.sample.reuse.form.controller.SalesOrder", {
onInit: function () {
var oJsonModel = new JSONModel({
data: {},
displayMode: "D"
});
this.getView().setModel(oJsonModel, "FormDataModel");
var oDataModel = this.getOwnerComponent().getModel();
var sPath = "/SoheaderdataSet('500000000')";
oDataModel.read(sPath, {
success: this._onSalesOrderReadSuccess.bind(this),
error: this._onSalesOrderReadFail.bind(this)
});
},
onSalesOrderEdit: function () {
this.getView().getModel("FormDataModel").setProperty("/displayMode", "E");
this.getView().byId("idSalesOrderDetails").refresh();
},
onSalesOrderDisplay: function () {
this.getView().getModel("FormDataModel").setProperty("/displayMode", "D");
this.getView().byId("idSalesOrderDetails").refresh();
},
onSalesOrderSave: function(){
this.byId("idSalesOrderDetails").validate();
},
_onSalesOrderReadSuccess: function (oResponse) {
this.getView().getModel("FormDataModel").setProperty("/data", oResponse);
},
_onSalesOrderReadFail: function () {
MessageToast.show("Error in Reading Sales Order Details");
}
});
});
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
22 | |
14 | |
11 | |
11 | |
9 | |
8 | |
7 | |
7 | |
7 | |
6 |