当前位置: 首页 > news >正文

Fiori学习专题四十一:表单控件

上节课我们学习了一些单一控件的使用,但是我们发现在页面内每个控件都占用了一行,这样子就显得不太好看,这节课我们引入一个表单控件来美化一下这个页面。
1.学习表单控件FORM之前我们先了解下哪些情况会使用到表单控件,最常见的场景就是需要我们输入一些字段,这时会弹出一个对话框给我们输入,例如这样:
在这里插入图片描述

2.那么我们学习使用Form控件。
首先打开API参考看下,在class sap.ui.layout.form命名空间下找到Form控件,可以看到Form控件的常用属性,以及其类型,我们同样可以通过类型穿透进去看到其内部又有其他的什么属性:
formContainers:展示Form内容
layout:布局设置
title:标题
toolbar:工具栏
API样例Form。
在这里插入图片描述
3.基本上我们的学习思路就是这样,通过API了解控件,再通过样例去熟悉其中的用法。
4.我们根据样例,将上节课的页面修改一下,引入表单控件的命名空间
xmlns:l=“sap.ui.layout”
xmlns:f=“sap.ui.layout.form”
再分别将<f:title><f:formContainers> <f:layout>这几个属性嵌入进去,最后修改完就是这样子。其中layout属性里面有
columnsM=“2”
columnsL=“4”
columnsXL=“4”
指的是表单的列数,其中XL/L/M指的是界面尺寸,可以理解为不同设备展示时列数不同


<mvc:ViewcontrollerName="democontrol.controller.Overview"xmlns:mvc="sap.ui.core.mvc"xmlns="sap.m"xmlns:core="sap.ui.core"xmlns:l="sap.ui.layout"xmlns:f="sap.ui.layout.form"displayBlock="true"
>
<Page id="idpage"><HBox id="Vbox" class="sapUiSmallMargin"><f:Formid="FormDisplayColumn_oneGroup234"editable="false"><f:title><core:Titleid="idformtitle"text="Address"/></f:title><f:layout><f:ColumnLayoutid="idColumnLayout"columnsM="2"columnsL="4"columnsXL="4"/></f:layout><f:formContainers><f:FormContainer id="idFormContainer"><f:formElements><f:FormElementid="idButton"label="Button"><f:fields><Buttonid="button_hello"text="{i18n>hellotext}"press=".onSayHello"icon="sap-icon://world"/></f:fields></f:FormElement><f:FormElementid="idInput"label="Label"><f:fields><Inputid="productInput"placeholder="Enter product"showSuggestion="true"suggestionItems="{invoices>/Invoices}"showValueHelp="true"valueHelpRequest=".onValueHelpRequest"><suggestionItems><core:Itemid="suggestionItem"text="{invoices>ProductName}"/></suggestionItems></Input></f:fields></f:FormElement><f:FormElementid="idText"label="Label"><f:fields><Textid="tetx1"text="{firstModel>/text1}"/></f:fields></f:FormElement><f:FormElementid="idCheckBox1"label="Label"><f:fields><CheckBoxid="CheckBoxA"selected="true"text="option A"select="onSelectCheckBoxA"/></f:fields></f:FormElement><f:FormElementid="idCheckBox2"label="Label"><f:fields><CheckBoxid="CheckBoxB"selected="false"text="option B"select="onSelectCheckBoxB"/></f:fields></f:FormElement><f:FormElementid="idRadioButtonGroup"label="Label"><f:fields><RadioButtonGroupid="rbg2"columns="1"selectedIndex="2"class="sapUiMediumMarginBottom"select="onSelectRadio"><RadioButtonid="RB2-1"text="Option 1"/><RadioButtonid="RB2-2"text="Option 2"editable="false"/><RadioButtonid="RB2-3"text="Option 3"/></RadioButtonGroup></f:fields></f:FormElement><f:FormElementid="idSwitch1"label="Label"><f:fields><Switchid="switchId1"state="true"customTextOn="Yes"customTextOff="No"change="onSwitchChange1"/></f:fields></f:FormElement><f:FormElementid="idSwitch2"label="Label"><f:fields><Switchid="switchId2"type="AcceptReject"state="true"customTextOn="Yes"customTextOff="No"change="onSwitchChange2"/></f:fields></f:FormElement><f:FormElementid="idComboBox1"label="Label"><f:fields><ComboBoxid="comboBox1"change="onChangeCombox"><items><core:Itemid="comboBoxitem1"text="Yes"key="true"/><core:Itemid="comboBoxitem2"text="No"key="false"/></items></ComboBox></f:fields></f:FormElement><f:FormElementid="idComboBox2"label="Label"><f:fields><ComboBoxid="comboBox2"items="{SuggestModel>/}"change="onChangeCombox"selectedKey="{SuggestModel>/}"><items><core:Itemid="comboBox2item"text="{SuggestModel>value}"key="{SuggestModel>key}"/></items></ComboBox></f:fields></f:FormElement><f:FormElementid="idSelect1"label="Label"><f:fields><Select id="select1"><items><core:Itemid="selectitem1"text="Yes"key="true"/><core:Itemid="selectitem2"text="No"key="false"/></items></Select></f:fields></f:FormElement><f:FormElementid="idSelect2"label="Label"><f:fields><Selectid="select2"items="{suggestModel>/}"><items><core:Itemid="select2item"text="{suggestModel>value}"key="{suggestModel>key}"/></items></Select></f:fields></f:FormElement></f:formElements></f:FormContainer></f:formContainers></f:Form></HBox></Page>
</mvc:View>

当我们使用电脑显示时展示为4列
在这里插入图片描述
切换为Ipad尺寸时展示为了2列
在这里插入图片描述
5.表单控件我们初步了解到这里,有更深入的需求只需要查看样例,基本上都有。

相关文章:

  • Gemini 2.5 推动视频理解进入新时代
  • Python爬虫常用项
  • 数据结构——例题1
  • [特殊字符]CentOS 7.6 安装 JDK 11(适配国内服务器环境)
  • LeetCode热题100--206.反转链表--简单
  • MongoDB 的主要优势和劣势是什么?适用于哪些场景?
  • LeetCode 热题 100_多数元素(97_169_简单_C++)(哈希表;排序)
  • 【2025年前端高频场景题系列】使用同一个链接,如何实现PC打开是web应用、手机打是-个H5 应用?
  • UE5通过C++实现TcpSocket连接
  • X1A000171000300,FC2012AN,32.768kHz,2012mm,EPSON晶振
  • 【Flask全栈开发指南】从零构建企业级Web应用
  • 影刀RPA开发-CSS选择器介绍
  • 第三章 初始化配置(一)
  • 【C++详解】类和对象(上)类的定义、实例化、this指针
  • esp32硬件支持AT指令
  • Leetcode 3544. Subtree Inversion Sum
  • 【Nova UI】十五、打造组件库之滚动条组件(上):滚动条组件的起步与进阶
  • Electron-Vue3、Electron-React、Electron-Angular打造舆情监控系统项目
  • Java SE(12)——异常(Exception)
  • InternVL3: 利用AI处理文本、图像、视频、OCR和数据分析
  • 季子文化与江南文化的根脉探寻与融合
  • 上海浦东机场1号、2号航站楼均推出国内出发安检24小时服务
  • 来伊份深夜回应“粽子中吃出疑似创可贴”:拿到实物后会查明原因
  • 中方发布会:中美经贸高层会谈氛围是坦诚的、深入的、具有建设性的
  • 中国海外发展:今年前4个月销售665.8亿元,花费305亿元拿地
  • 身临其境感受伟人思想力量,“马克思书房”在上海社科馆揭幕