Skip to Content

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

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

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

4 Answers

  • Best Answer
    Posted on Dec 31, 2018 at 05:51 AM

    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

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Dec 28, 2018 at 06:07 AM

    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

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Dec 31, 2018 at 12:21 PM

    Thanks Rabin Dhas and Mahesh Kumar Palavalli for your valuable time.

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Jul 24, 2020 at 05:29 AM

    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

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.