cancel
Showing results for 
Search instead for 
Did you mean: 

SmartField not working in FIORI

developerone
Contributor

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

Accepted Solutions (1)

Accepted Solutions (1)

developerone
Contributor

Hi Pratheek,

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

@ObjectModel.updateEnabled: true

Regards,

Kabir

Answers (1)

Answers (1)

pratheek_kv2
Explorer
0 Kudos

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