cancel
Showing results for 
Search instead for 
Did you mean: 

How to read multiple sap.ui.layout.form values.

0 Kudos
553

Hi,

I have a fragment from which I would like to read multiple sap.ui.layout.form values.

Since i had used .clone() functionality to add the rows dynamically, i would like to read all the form values at a single shot instead of accessing byId() for each row.

Any advice is deeply appreciated

Thanks,

Natarajan

Accepted Solutions (1)

Accepted Solutions (1)

former_member254395
Active Participant
0 Kudos

Hi ,

incase of getting form field values, you shall loop the form and get cells and its values as below

var oFromFields = sap.ui.getCore().byId("formId")).getFormContainers()[0].getAggregation( "formElements");

loop the elements to get its values

Answers (3)

Answers (3)

former_member374496
Participant
0 Kudos

Hi Natarajan,

I have a similar requirement to add and remove the elements dynamically and read them all at once when you submit, also facing ans issue with the Layout, i see you have done it right the layout in a panel could please tell me how did arrange the UI elements and how to read all at once when u submit?

Thanks in advance,

Pradeep

0 Kudos

Thanks rabin.dhas and maheshkumar.palavalli for your valuable time.

maheshpalavalli
Active Contributor
0 Kudos

Hi Natarajan Srikanta,

You could use the json model to do this for you. As the form has the form containers aggregation binding and form container has form elements aggregation binding, you can bind the model to this and generate the new rows without cloning just by adding a new row in the json model data, which will automatically add the row to the aggregation. This is a better approach as getting the data byId is very unreliable.

1. Create a json model with initially one row

2. Use the factory functionality to generate the item template dynamically for your form items, as you are generating different controls dynamically for different rows.

3. When the add button is clicked, add another row to the json model, which will automatically trigger your factory function and you will pass the template back to the form.

Also you can do the same using the odata model, but you need to get the template and use the element binding and trigger submit changes at the end, but this will trigger the post call.

BR,

Mahesh

0 Kudos

Hi Mahesh,

Thanks for your advice.

I had followed your steps and could achieve the result partially following this reference:-http://embed.plnkr.co/ZGLFDZ5atpzYGrcVuHPb/

I'm facing issue while adding the ui elements(input,select,input,add and delete button) row dynamically to panel and reading those values

Any code reference will be helpful.

Thanks,

Natarajan

maheshpalavalli
Active Contributor
0 Kudos

Hi Srikanta,

I've modified the plnkr link you have sent.

https://next.plnkr.co/edit/OzETNrb1mmkMGk3r?preview

You have to use the factory function to dynamically generate the ui elements and use the json model to insert the rows on click of add.

This is really a difficult task to do and I would sugest you to use the value help comp that is provided by sap which makes the things way easier.

Factory: https://ui5.sap.com/#/topic/284a036c8ff943238fb65bf5a2676fb7

BR,

Mahesh