[UI5 常用控件] 06.Splitter,ResponsiveSplitter

文章目录

  • 前言
  • [1. Splitter](#1. Splitter)
    • [1.1 属性](#1.1 属性)
  • [2. ResponsiveSplitter](#2. ResponsiveSplitter)

前言

本章节记录常用控件Splitter,ResponsiveSplitter。主要功能是分割画面布局。

其路径分别是:

  • sap.ui.layout.Splitter
  • sap.ui.layout.ResponsiveSplitter

1. Splitter

1.1 属性

  • orientation : Horizontal,Vertical (横向分割/纵向分割)
  • SplitterLayoutData:size : 尺寸
  • SplitterLayoutData:minSize : 最小尺寸
  • SplitterLayoutData:resizable : 可变尺寸
  • View
xml 复制代码
	<Panel headerText="Splitter 布局">
	    <l:Splitter
	        id="mainSplitter"
	        height="500px"
	        width="100%"
	        orientation="Horizontal"
	    >
	        <Button
	            width="100%"
	            text="Content 1"
	        >
	            <layoutData>
	                <l:SplitterLayoutData size="300px" />
	            </layoutData>
	        </Button>
	        <Button
	            width="100%"
	            text="Content 2"
	        >
	            <layoutData>
	                <l:SplitterLayoutData size="auto" />
	            </layoutData>
	        </Button>
	        <Button
	            width="100%"
	            text="Content 3"
	        >
	            <layoutData>
	                <l:SplitterLayoutData
	                    size="30%"
	                    minSize="200px"
	                />
	            </layoutData>
	        </Button>
	    </l:Splitter>
	    <HBox class="sapUiSmallMarginTop sapUiSmallMarginBegin">
	        <Button
	            text="Add content area"
	            press="btnAddContentArea"
	        />
	        <Button
	            text="Remove content area"
	            press="btnRemoveContentArea"
	        />
	        <Button
	            text="Resizable"
	            press="btnSetResizable"
	        />
	        <Button
	            text="Change Orientation"
	            press="btnChangeOrientation"
	        />
	    </HBox>
	</Panel>
  • Controller
js 复制代码
	btnAddContentArea: function () {
	    var oLayoutData = new SplitterLayoutData({
	        resizable: true,
	        size: Math.random() > 0.5 ? "auto" : 50 + Math.floor(Math.random() * 300) + "px",
	        maxSize: Math.random() > 0.5 ? "0" : Math.floor(Math.random() * 100) + "px"
	    });
	
	    var oContent = new Button({
	        width: "100%",
	        height: "100%",
	        text: "Content!",
	        layoutData: oLayoutData
	    });
	
	    this.oSplitter.addContentArea(oContent);
	},
	btnRemoveContentArea: function () {
	    
	
	    var oLastContentArea = this.oSplitter.getContentAreas().pop();
	    this.oSplitter.removeContentArea(oLastContentArea);
	    oLastContentArea.destroy();
	},
	btnSetResizable:function(){
	    var oContentArea = this.oSplitter.getContentAreas()[0];
	    var oLayoutData = oContentArea.getLayoutData();
	
	    oLayoutData.setResizable(false)
	},
	btnChangeOrientation: function () {
	    var Orientation = coreLibrary.Orientation;
	    var sOr = this.oSplitter.getOrientation();
	    this.oSplitter.setOrientation(
	        sOr === Orientation.Vertical
	            ? Orientation.Horizontal
	            : Orientation.Vertical
	    );
	}

2. ResponsiveSplitter

  • Splitter另一个替代方案

  • View

xml 复制代码
   <Panel
        headerText="ResponsiveSplitter 布局"
        class="sapUiLargeMarginTop"
    >
        <l:ResponsiveSplitter
            defaultPane="default"
            height="600px"
        >
            <l:PaneContainer resize=".onRootContainerResize">
                <l:SplitPane
                    requiredParentWidth="400"
                    id="default"
                >
                    <l:layoutData>
                        <l:SplitterLayoutData size="40%" />
                    </l:layoutData>
                    <Panel
                        headerText="Minimum parent width 400"
                        height="100%"
                    >
                        <Button
                            text="Area 1"
                            width="50%"
                            type="Success"
                        />
                    </Panel>
                </l:SplitPane>
                <l:PaneContainer
                    orientation="Vertical"
                    resize=".onInnerContainerResize"
                >
                    <l:SplitPane requiredParentWidth="100">
                        <l:layoutData>
                            <l:SplitterLayoutData size="30%" />
                        </l:layoutData>
                        <Panel headerText="Minimum parent width 600">
                            <Button
                                text="Area 2"
                                width="50%"
                                type="Attention"
                            />
                        </Panel>
                    </l:SplitPane>
                    <l:SplitPane requiredParentWidth="800">
                        <l:layoutData>
                            <l:SplitterLayoutData size="70%" />
                        </l:layoutData>
                        <Page title="Minimum parent width 800">
                            <Button
                                text="Area 3"
                                width="50%"
                                type="Emphasized"
                            />

                            <footer>
                                <OverflowToolbar id="otb3">
                                    <Label text="Buttons:" />
                                    <ToolbarSpacer />
                                    <Button
                                        text="New"
                                        type="Transparent"
                                    />
                                    <Button
                                        text="Open"
                                        type="Transparent"
                                    />
                                    <Button
                                        text="Save"
                                        type="Transparent"
                                    />
                                    <Button
                                        text="Save as"
                                        type="Transparent"
                                    />
                                    <Button
                                        text="Cut"
                                        type="Transparent"
                                    />
                                    <Button
                                        text="Copy"
                                        type="Transparent"
                                    />
                                    <Button
                                        text="Paste"
                                        type="Transparent"
                                    />
                                    <Button
                                        text="Undo"
                                        type="Transparent"
                                    />
                                </OverflowToolbar>
                            </footer>
                        </Page>
                    </l:SplitPane>
                </l:PaneContainer>
            </l:PaneContainer>
        </l:ResponsiveSplitter>
    </Panel>
  • Controller
js 复制代码
	onRootContainerResize: function (oEvent) {
	    var aOldSizes = oEvent.getParameter("oldSizes"),
	        aNewSizes = oEvent.getParameter("newSizes"),
	        sMessage =  "Root container is resized.";
	
	    if (aOldSizes && aOldSizes.length) {
	        sMessage += "\nOld panes sizes = [" + aOldSizes + "]";
	    }
	
	    sMessage += "\nNew panes sizes = [" + aNewSizes + "]";
	
	    MessageToast.show(sMessage);
	},
	
	onInnerContainerResize: function (oEvent) {
	    var aOldSizes = oEvent.getParameter("oldSizes"),
	        aNewSizes = oEvent.getParameter("newSizes"),
	        sMessage =  "Inner container is resized.";
	
	    if (aOldSizes && aOldSizes.length) {
	        sMessage += "\nOld panes sizes = [" + aOldSizes + "]";
	    }
	
	    sMessage += "\nNew panes sizes = [" + aNewSizes + "]";
	
	    MessageToast.show(sMessage);
	}
相关推荐
数字化转型20257 天前
Alternative Reconciliation Accounts 备选统驭科目
sap
小九不懂SAP18 天前
6、定义字段状态变式
sap·s4
lu_rong_qq1 个月前
SAP B1 三大基本表单标准功能介绍-物料主数据(下)
数据库·sap·erp
仁,义1 个月前
其它特殊库存
sap·库存管理·特殊库存
李安迪是大神1 个月前
上传PDF、DOC文件到SAP HCM系统中案例
pdf·word·sap·abap·sap erp
集信通1 个月前
SAP和致远OA系统集成案例
人工智能·自动化·区块链·sap
数字化转型20252 个月前
SAP BRIM用于应收账款AR收入中台
大数据·microsoft·sap
荀彧原名苟或2 个月前
SAP MIGO屏幕增强的具体实施步骤介绍(SE19:MB_MIGO_BADI) <转载>
java·数据库·缓存·sap·abap
LilySesy2 个月前
ABAP小白开发操作手册+(九)ABAP调用http
开发语言·网络·网络协议·http·sap·abap
集信通2 个月前
某MDM主数据管理系统与微软Dynamic CRM系统(新加坡节点)集成案例
microsoft·中间件·自动化·sap