Search code examples
javascriptodatasapui5

How to create controls based on the backend response in sapui5?


I want to generate a UI based on backend data provided in a service.

My Service will look like below:

    {
    "ControlData": {
        "results": [{
            "Label": "Gender?",
            "Type": "COMBOBOX"
        }],
        "ControlValues": {
            "results": [{
                    "Key": "M",
                    "Value": "Male"
                },
                {
                    "Key": "F",
                    "Value": "Female"
                }
            ]
        }
    }
}

Here I want to generate a ComboBox control with label and values provided in the service dynamically.

Please provide me any example or reference to do so.


Solution

  • You need to use factory functions

    Using Factory Functions

    Step 15: Aggregation Binding Using a Factory Function