gpt4 book ai didi

sapui5 - 如何使用按钮使简单的表单响应

转载 作者:行者123 更新时间:2023-12-01 15:02:53 24 4
gpt4 key购买 nike

我制作了一个简单的表单,其中包含一个输入字段和两个按钮,定义如下:

<core:FragmentDefinition
xmlns="sap.m"
xmlns:l="sap.ui.layout"
xmlns:f="sap.ui.layout.form"
controllerName="com.techmo.controller.Table"
xmlns:core="sap.ui.core">
<Page
class="employePageBackGroundColor"
showHeader="false">
<f:SimpleForm
id="EmployeeSimpleForm"
editable="true"
layout="ResponsiveGridLayout"
labelSpanL="4"
labelSpanM="4"
labelSpanS="6"
adjustLabelSpan="True"
emptySpanL="0"
emptySpanM="0"
emptySpanS="6"
columnsL="1"
columnsM="1"
singleContainerFullSize="false" >
<f:content>
<Label text="Employee Name" reqiured="true">
<layoutData>
<l:GridData span="L2 M3 S6"/>
</layoutData>
</Label>
<Input id="empname">
<layoutData>
<l:GridData span="L2 M3 S6"/>
</layoutData>
</Input>

如果我在这里添加按钮,它在移动 View 中没有响应按钮被截断并进入下一行。我是 ui5 的新手,任何人都可以帮我解决这个问题,谢谢
 <Button class="search" type="Emphasized" text="Search" press="onSearch" icon="sap-icon://search">
<layoutData>
<l:GridData span="L2 M2 S2"/>
</layoutData>
</Button>

<Button class="userAddButton" text="ADD" press="onAddCustomer" icon="sap-icon://add-employee">
<layoutData>
<l:GridData span="L5 M2 S12"/>
</layoutData>
</Button>
</f:content>
</f:SimpleForm>

最佳答案

根据我的理解,我对你的问题有两个答案

按钮彼此相邻

<Button class="search" type="Emphasized" text="Search" press="onSearch" icon="sap-icon://search">
<layoutData> <l:GridData span="L2 M2 S6"/> </layoutData>
</Button>
<Button class="userAddButton" text="ADD" press="onAddCustomer" icon="sap-icon://add-employee">
<layoutData> <l:GridData span="L5 M2 S6"/> </layoutData>
</Button>

enter image description here

不同行/行中的按钮
<Button class="search" type="Emphasized" text="Search" press="onSearch" icon="sap-icon://search">
<layoutData> <l:GridData span="L2 M2 S12"/> </layoutData>
</Button>
<Button class="userAddButton" text="ADD" press="onAddCustomer" icon="sap-icon://add-employee">
<layoutData> <l:GridData span="L5 M2 S12"/> </layoutData>
</Button>

enter image description here

同一行/行中的输入和按钮
<Label text="Employee Name">
<layoutData> <l:GridData span="L2 M2 S12"/> </layoutData>
</Label>
<Input id="empname">
<layoutData> <l:GridData span="L6 M6 S4"/> </layoutData>
</Input>
<Button class="search" type="Emphasized" text="Search" press="onSearch" icon="sap-icon://search" >
<layoutData> <l:GridData span="L2 M2 S4"/> </layoutData>
</Button>
<Button class="userAddButton" text="ADD" press="onAddCustomer" icon="sap-icon://add-employee">
<layoutData> <l:GridData span="L2 M2 S4"/> </layoutData>
</Button>

enter image description here

注意:像 iPhone 5/SE 这样具有最小屏幕分辨率的移动设备,按钮文本将被截断。解决方案只是显示没有文本的图标。

完整代码
<mvc:View
controllerName="com.techmo.controller.ManageEmployee"
xmlns:core="sap.ui.core"
xmlns:mvc="sap.ui.core.mvc"
xmlns="sap.m"
xmlns:fb="sap.ui.comp.filterbar"
xmlns:l="sap.ui.layout"
xmlns:f="sap.ui.layout.form"
xmlns:html="http://www.w3.org/1999/xhtml">
<Page
class="employePageBackGroundColor"
showHeader="false">
<f:SimpleForm
id="EmployeeSimpleForm"
editable="true"
layout="ResponsiveGridLayout"
labelSpanL="4"
labelSpanM="4"
labelSpanS="6"
adjustLabelSpan="True"
emptySpanL="0"
emptySpanM="0"
emptySpanS="0"
columnsL="1"
columnsM="1"
singleContainerFullSize="false" >
<f:content>
<Label text="Employee Name">
<layoutData>
<l:GridData span="L2 M2 S12"/>
</layoutData>
</Label>
<Input id="empname" >
<layoutData>
<l:GridData span="L6 M6 S4"/>
</layoutData>
</Input>
<Button class="search" type="Emphasized" text="Search" press="onSearch" icon="sap-icon://search" >
<layoutData>
<l:GridData span="L2 M2 S4"/>
</layoutData>
</Button>
<Button class="userAddButton" text="ADD" press="onAddCustomer" icon="sap-icon://add-employee">
<layoutData>
<l:GridData span="L2 M2 S4"/>
</layoutData>
</Button>
</f:content>
</f:SimpleForm>
</Page>
</mvc:View>

关于sapui5 - 如何使用按钮使简单的表单响应,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58339035/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com