SAPUI5教程——ActionSheet的应用
2017-07-01 08:50
246 查看
前言
ActionSheet是一个点击弹出popover的基本效果,可以让用户执行一定操作事件,如下图:定义controller
sap.ui.define(['sap/ui/core/Fragment','sap/ui/core/mvc/Controller'], function(Fragment, Controller) { "use strict"; var CController = Controller.extend("richard.demo.ActionSheet.C", { handleOpen : function (oEvent) { var oButton = oEvent.getSource(); // create action sheet only once if (!this._actionSheet) { this._actionSheet = sap.ui.xmlfragment( "richard.demo.ActionSheet.ActionSheet", this ); this.getView().addDependent(this._actionSheet); } this._actionSheet.openBy(oButton); } }); return CController; });
代码中主要通过sap.ui.xmlfragment实例加载一个fragment,添加到当前view当中。并公国openBy执行打开的操作。
定义ActionSheetFragment
<core:FragmentDefinition xmlns="sap.m" xmlns:core="sap.ui.core"> <ActionSheet title="Choose Your Action" showCancelButton="true" placement="Bottom"> <buttons> <Button text="Reject" icon="sap-icon://decline" /> <Button text="Accept" icon="sap-icon://accept" /> <Button text="Email" icon="sap-icon://email" /> <Button text="Forward" icon="sap-icon://forward" /> <Button text="Delete" icon="sap-icon://delete" /> <Button text="Other" /> </buttons> </ActionSheet> </core:FragmentDefinition>
fragment的定义可以通过core:FragmentDefinition来定义,已达到部分view的重用效果。
定义触发的按钮,打开actionsheet
<Button text="Open Action Sheet" press="handleOpen" class="sapUiSmallMarginBottom" />
这里主要是通过Button的press方法触发handleOpen,执行controler中的fragment加载操作,并打开。
相关文章推荐
- SAPUI5教程——更改ODataModel默认的请求方式
- SAPUI5教程——URLHelper的使用技巧
- SAPUI5教程——MessageStrip的应用场景
- SAPUI5教程——如何改变SAP Fiori登陆页面的背景图片
- SAPUI5教程——SAP WEB IDE崩溃
- SAPUI5教程——实现倒计时控制Button是否可以点击效果
- SAPUI5教程——最全中文学习指南(必看)
- SAPUI5教程—— Link的基本用法
- SAPUI5教程——安装Hybrid Application Tools失败
- SAPUI5教程——ABAP环境下SAP Fiori 系统搭建以及开发实践
- SAPUI5教程——在XML View中使用$运算符
- SAPUI5教程——SAP Fiori应用类型分析(Transactional, Fact Sheets, Analytical)
- SAPUI5教程——can not load launchpad Tile问题解决方案
- SAPUI5教程——框架简介以及应用实践
- SAPUI5教程——The project is corrupted because its '.user.project.json' file has an invalid JSON
- SAPUI5教程——Aggregation Binding的应用
- SAPUI5教程——清除SAP Fiori服务缓存
- SAPUI5教程——查看系统安装的SAPUI5版本
- SAPUI5教程——MaskInput的妙用
- SAPUI5教程——Content Densities