You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何在SAP UI5 SimpleForm中实现换行?

How to Add Line Breaks in SAP UI5 SimpleForm (ResponsiveGridLayout)

Hey there! Let's break down how to insert line breaks in your SimpleForm that's using the ResponsiveGridLayout. Since this layout is built on the UI5 Grid system, we have two straightforward, reliable approaches:


1. Use a Spacer to Force a Full-Width Break

Add a sap.ui.layout.Spacer that spans the entire width of the grid. This acts as a blank row, pushing all subsequent controls to a new line.

Here's how to modify your existing code to add a break right after the "Customer" input:

<f:SimpleForm title="Address" editable="true" layout="ResponsiveGridLayout" columnsM="2">
  <f:content>
    <Label text="Customer" />
    <Input>
      <layoutData>
        <l:GridData span="XL4 L4 M12 S12"/>
      </layoutData>
    </Input>
    <!-- This spacer creates a full-width line break -->
    <l:Spacer>
      <layoutData>
        <l:GridData span="XL12 L12 M12 S12"/>
      </layoutData>
    </l:Spacer>
    <Label text="PO reference">
      <layoutData>
        <l:GridData span="XL1 L1 M12 S12"/>
      </layoutData>
    </Label>
    <Input>
      <layoutData>
        <l:GridData span="XL4 L4 M12 S12"/>
      </layoutData>
    </Input>
  </f:content>
</f:SimpleForm>

The spacer takes up 12 columns (full width) across all screen breakpoints, ensuring a clean line break every time.


2. Use the lineBreak Property in GridData

For a more targeted break, you can set lineBreak="true" on the GridData of the control where you want the new line to start. This tells the grid to place that control and its paired element on a fresh row.

Example: If you want the "PO reference" label and input to start on a new line, update its layoutData like this:

<Label text="PO reference">
  <layoutData>
    <l:GridData span="XL1 L1 M12 S12" lineBreak="true"/>
  </layoutData>
</Label>

This works even if there's remaining space in the current row, giving you precise control over where the break happens.


Quick Notes:

  • Ensure you've declared the l namespace in your view (typically xmlns:l="sap.ui.layout"), which you likely already have since you're using GridData.
  • Test your line breaks across all screen sizes (S/M/L/XL) to make sure the responsive behavior matches your expectations.

内容的提问来源于stack exchange,提问作者softshipper

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.27 04:09:08