cancel
Showing results for 
Search instead for 
Did you mean: 

UI5 JSON data binding for textfields in a simple Form

sandesh_satpute
Explorer
0 Kudos

Experts,

I have employee data in JSON format(text file attached). I am using sap.ui.layout.form.Form to display the employee’s First Name. Currently I have 3 employees in the file. My question is how can dynamically show the employee's First Name in the form fields. By dynamically I mean, I don’t want to use the code that I am currently using below to display data against the “value” in the text field? Can I substitute the path that is used against the “value” say, by a variable such as employee id , and  can display first name?

new sap.ui.layout.form.FormContainer({

       formElements: [

                  new sap.ui.layout.form.FormElement({

fields: [new sap.ui.commons.TextField({

                                                                  value: "{/employees/employee/0/firstName}",

                                                                   width: "50px"                                                                                                     

                                                                  })

Accepted Solutions (0)

Answers (1)

Answers (1)

Former Member
0 Kudos

So you want to show form for each employee?

You can use row repeater (sap.ui.commons.RowRepeater) and bind the rows aggregation to "{ path: '/employees/employee' }"

the rows content will be your form with Fisrtname set to "{firstName}"

sandesh_satpute
Explorer
0 Kudos

Hi Vaibhav,

Thanks for your reply. I am trying to display employee details in the form. So  dont want to display all the employees, just the selected employee in the form. As of now I haven't written the code for selection/filter criteria. Thats why is I want pass variable such as employee number and show employee first name in the textField.