Skip to Content

SmartField not working in FIORI

Hello,

I created an app using FIORI elements with the following steps:

1. Created CDS view

2. Published ODATA service

3. Used the service to create a List Report

4. Used extensions to create a List Report action

5. Added the code to display a pop up with input field which has a search help.

Problem:

The pop up displays the input field like a label or the input field is not getting displayed.

	var oModel = this.getView().getModel();
		var oForm = new sap.ui.layout.form.SimpleForm({
			editable: true
		});

		var sParameterLabel = "Employee";
		var sBinding = "{emp}";
		debugger;
		var oField = new sap.ui.comp.smartfield.SmartField({
			value: sBinding
		});
		var sLabel = new sap.ui.comp.smartfield.SmartLabel();
		sLabel.setText(sParameterLabel);
		sLabel.setLabelFor(oField);
		oForm.addContent(sLabel);
		oForm.addContent(oField);

		var oParameterDialog = new sap.m.Dialog({
			title: "Assign New Employee",
			content: [oForm],
			beginButton: new sap.m.Button({
				text: "OK",
				press: function() {
				}
			}),
			endButton: new sap.m.Button({
				text: "Cancel",
				press: function() {
					oParameterDialog.close();
				}
			}),
			afterClose: function() {
				oParameterDialog.destroy();
			}
		});

		oParameterDialog.setModel(oModel);
		oParameterDialog.open();

What is going wrong ?

Thanks,

Kabir

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

2 Answers

  • Best Answer
    Feb 05 at 09:01 PM

    Hi Pratheek,

    Thanks for the response. I set this annotation in my CDS view and it began to work.

    @ObjectModel.updateEnabled: true

    Regards,

    Kabir

    Add comment
    10|10000 characters needed characters exceeded

  • Feb 04 at 02:55 PM

    Hi Kabir,

    Did you try setting "contextEditable" property of SmartField? This should solve the problem.

    And Just for your Information,

    Along with your model, Fiori Elements also creates a Model at Runtime named "UI" set to the View and Component. This Model has a property called "editable" which can be used by developers to set the editability of your extended controls.

    contextEditable={ui>/editable} in short.

    Regards,

    Pratheek

    Add comment
    10|10000 characters needed characters exceeded