Skip to Content
-1
Apr 05, 2017 at 08:54 AM

Adding Form Container and Form Elements Dynamically in UI5

2325 Views

Hi All,

Am trying to create a form using below lines of code.

var proposalLayout = new sap.ui.layout.form.GridLayout("L2"); var proposalForm = new sap.ui.layout.form.Form("proposalForm",{ editable: true, layout: proposalLayout, formContainers: [ new sap.ui.layout.form.FormContainer({ //title: "Proposed Solution", formElements: [ new sap.ui.layout.form.FormElement({ label: "Solution Name", fields: [new sap.m.Input("solNameInput",{layoutData: new sap.ui.layout.form.GridElementData({hCells: "13"})})] }), new sap.ui.layout.form.FormElement({ label: "Prepared by", fields: [new sap.m.Input("preparedByInput",{ layoutData: new sap.ui.layout.form.GridElementData({hCells: "13"})})] }) ] }), new sap.ui.layout.form.FormContainer({ title: "Case Benefits", formElements: [ new sap.ui.layout.form.FormElement({ label: new sap.m.Label({text: "Cost"}), fields: [new sap.m.Input("costInput",{layoutData: new sap.ui.layout.form.GridElementData({hCells: "1"})})] }) ], layoutData: new sap.ui.layout.form.GridContainerData({halfGrid: true}) }), new sap.ui.layout.form.FormContainer({ formElements: [ new sap.ui.layout.form.FormElement({ label: new sap.m.Label({text: "Benefits"}), fields: [new sap.m.Input("benefitsInput",{layoutData: new sap.ui.layout.form.GridElementData({hCells: "1"})})] }) ], layoutData: new sap.ui.layout.form.GridContainerData({halfGrid: true}) }), ] });

Now again i need to regenerate the same form when i click on a Button.

Could any body please help me to acheive this functionality