
<Input id="test1" width="10rem" showValueHelp="true" valueHelpRequest="onValueRequest"/>
<HBox width="1px" height="1px" id="invisibleBox" class="invisible">
</HBox>
<Input/>
onValueRequest: function() {
/*create the smartfield for using its value help*/
var oSmartFiled = new SmartField({
value:{
path: 'salesOrganization'
}
});
/* Set the selected value to Input Field*/
oSmartFiled.attachChange(() => {
var sValue = oSmartFiled.getValue();
this.getView().byId("test1").setValue(sValue);
oSmartFiled.destroy();
})
/* overwrite the prototype function of this smartfield for adding custom logic to
Promise chain,
Source Code copied from sap.ui.comp.smartfield.SmartField*/
oSmartFiled._createICRenderedDeferred = function () {
var oDef;
oDef = new Deferred();
this._oRenderedWithContext = oDef;
Promise.all([
new Promise(function (fnResolve) {
this.attachInnerControlsCreated(fnResolve);
}.bind(this)),
new Promise(function (fnResolve) {
var oDelegate = {
onAfterRendering: function (oEvent) {
var oFocusCatcher = this._getFocusCatcher(),
oEditControl = this._oControl.edit,
oContent = this.getAggregation("_content");
if (
oEditControl &&
oEditControl.getDomRef() &&
oEditControl.getFocusDomRef() &&
oEditControl === oContent &&
(
!oFocusCatcher ||
!oFocusCatcher.getDomRef()
)
) {
this.removeEventDelegate(oDelegate);
fnResolve();
}
}.bind(this)
};
this.addEventDelegate(oDelegate);
}.bind(this))
]).then(function () {
oDef.resolve();
})
/*Add custom code to the Promise chain for ensure getting the rendered inner
InputField of Smartfield,
and then fire its "ValueHelpRequest" Event to show the Value Help Dialog
*/
.then(
() => {
try{
var sId = oSmartFiled.getId();
var oInput = sap.ui.getCore().byId(`${sId}-input`);
oInput.fireValueHelpRequest();
}catch(reason) {
}
}
);
};
/* Get the ODatamodel which be defined in manefest.json,
bind the ODatamodel to smartfield
add the smartfield to invisible FlexBox
*/
var oSalesModel = this.getOwnerComponent().getModel("salesOData");
var oNewItem = oSalesModel.createEntry("/Z_C_SOHEADER_L2");
oSmartFiled.setModel(oSalesModel);
oSmartFiled.setBindingContext(oNewItem);
var oFlexBox = this.getView().byId("invisibleBox");
oFlexBox.addItem(oSmartFiled);
}
The value help dialog from Smart Field which opened by normal Input Field
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
15 | |
10 | |
8 | |
7 | |
7 | |
6 | |
5 | |
5 | |
4 | |
4 |