on 2021 Sep 23 11:33 AM
Hi Experts,
I am having trouble on rendering question list data with yes or no radio field or switch field on my Form, data are coming from OData service. So the input fields that I need are in the service, my problem is how can I render it on simpleForm, other personal information are manually added on simpleForm , below the form I need to render the questions, but the problem is I don't know how to loop it, I tried using List but it affects the responsiveness and layout of the form.

Request clarification before answering.
Hi, Jocel. You can use <VBox>.
<VBox items=“{yourModel>/items}”>
<!— your switch —>
</VBox>
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Vinicius,
I tried it and works fine, the only problem now is the layout:
It is not align with the simple form, is it alright to remove the SimpleForm ? , If I remove the simple form I can still submit the form without that right?
<form:SimpleForm
id="assessmentForm"
title="Instruction #{oGeneralData>/instructionNo}"
layout="ResponsiveGridLayout"
editable="true"
class="sapUiResponsiveMargin"
width="auto"
labelSpanL="3" labelSpanM="3"
emptySpanL="4" emptySpanM="4"
columnsL="1" columnsM="1">
<form:content>
<Label
labelFor="cmId"
required="true"
text="{i18n>afCmId}" />
<Input
id="cmId"
type="Number"
placeholder="{i18n>afCmIdPlaceHolder}"/>
<Label
labelFor="cmENum"
required="true"
text="{i18n>afECmNo}" />
<Input
id="cmENum"
type="Number"/>
<Label
labelFor="cmDepartment"
required="true"
text="{i18n>afCmDepartment}" />
<Input
id="cmDepartment"
type="Text"/>
<Label
labelFor="cmTitle"
required="true"
text="{i18n>afcmTitle}" />
<Input
id="cmTitle"
type="Text"/>
<Label
labelFor="shipId"
required="true"
text="{i18n>afShip}" />
<Select
id="shipId"
forceSelection="false"
items="{
path: 'musterdrillData>/ships',
sorter: {
path: 'name'
}
}">
<core:Item key="{musterdrillData>id}" text="{musterdrillData>name}" />
</Select>
<Label
labelFor="drillColor"
required="true"
text="{i18n>afDrillColor}"/>
<SegmentedButton
id="drillColor"
selectedKey="{oGeneralData>/color}"
items="{musterdrillData>/drillSelections}">
<items>
<SegmentedButtonItem
text="{musterdrillData>title}"
enabled="{musterdrillData>isActive}"
key="{musterdrillData>value}"/>
</items>
</SegmentedButton>
<Label
labelFor="q1"
required="true"
text="1.1 [Emergency Organization] Was the correct announcement made?" />
<Switch id="q1" state="true" customTextOn="Yes" customTextOff="No">
<layoutData>
<FlexItemData growFactor="1" />
</layoutData>
</Switch>
<Label
labelFor="n1"
text="1.1 - Notes" />
<TextArea
id="n1"
growing="false"
growingMaxLines="0"
height=""
maxLength="0"
rows="4"
>
</TextArea>
<Label
labelFor="q2"
required="true"
text="1.2 [Emergency Duty] Was FCP reported from OFCS?" />
<Switch id="q2" state="true" customTextOn="Yes" customTextOff="No">
<layoutData>
<FlexItemData growFactor="1" />
</layoutData>
</Switch>
<Label
labelFor="n2"
text="1.2 - Notes" />
<TextArea
id="n2"
growing="false"
growingMaxLines="0"
height=""
maxLength="0"
rows="4"
>
</TextArea>
<VBox
items="{musterdrillData>/drillSelections}"
>
<items>
<HBox>
<VBox>
<Label
required="true"
text="{musterdrillData>title}">
</Label>
</VBox>
<VBox>
<Switch state="true" customTextOn="Yes" customTextOff="No">
</Switch>
</VBox>
</HBox>
</items>
</VBox>
</form:content>
</form:SimpleForm>
Right.
Also, if you want to dynamically add content - you can do that in your view controller.
I tried using the below code in my dev space, and it adds with proper alignment.
You will get more flexibility with your data by doing this programmatically.
var oForm = this.getView().byId('<Your_Form_ID>');
for (let index = 0; index < arr.length; index++) {
oForm.addContent( new sap.m.Label({ text: arr[index] }) );
oForm.addContent( new sap.m.Input({ type: sap.m.InputType.Text, placeHolder: "Some Text" }) );
}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You can use the below method
<List headerText="Text" items="{path: '/Collection'}" >
<CustomListItem>
<HBox>
<VBox >
<Link text="{Name}" target="{Url}" press="handlePress"/>
<Label text="{Desc}"/>
</VBox>
</HBox>
</CustomListItem>
</List>
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
| User | Count |
|---|---|
| 12 | |
| 9 | |
| 7 | |
| 5 | |
| 4 | |
| 3 | |
| 3 | |
| 2 | |
| 2 | |
| 2 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.