版权声明:如有转载请注明 by Huang.Lin https://blog.csdn.net/huanglin6/article/details/82417944
1.背景:在使用SAP UI5开发时候,会有需要使用到Mast-Detail的场景,比如实现"待办的显示",或者待办审批。在OPEN UI5库中有几个DEMO program 和DEMO APP。
2.效果
detail-page1:
detail-page2:
detail-page3:
Component.js
sap.ui.define(['sap/ui/core/UIComponent'],
function(UIComponent) {
"use strict";
var Component = UIComponent.extend("sap.m.sample.SplitApp.Component", {
metadata : {
rootView : {
"viewName": "sap.m.sample.SplitApp.V",
"type": "XML",
"async": true
},
dependencies : {
libs : [
"sap.m"
]
},
config : {
sample : {
files : [
"V.view.xml",
"C.controller.js"
]
}
}
}
});
return Component;
});
C.controller.js
sap.ui.define([
'jquery.sap.global',
'sap/m/MessageToast',
'sap/ui/core/Fragment',
'sap/ui/core/mvc/Controller',
'sap/ui/model/Filter',
'sap/ui/model/json/JSONModel'
], function(jQuery, MessageToast, Fragment, Controller, Filter, JSONModel) {
"use strict";
var CController = Controller.extend("sap.m.sample.SplitApp.C", {
onInit: function(){
this.getSplitAppObj().setHomeIcon({
'phone':'phone-icon.png',
'tablet':'tablet-icon.png',
'icon':'desktop.ico'
});
},
onOrientationChange: function(oEvent) {
var bLandscapeOrientation = oEvent.getParameter("landscape"),
sMsg = "Orientation now is: " + (bLandscapeOrientation ? "Landscape" : "Portrait");
MessageToast.show(sMsg, {duration: 5000});
},
onPressNavToDetail : function(oEvent) {
this.getSplitAppObj().to(this.createId("detailDetail"));
},
onPressDetailBack : function() {
this.getSplitAppObj().backDetail();
},
onPressMasterBack : function() {
this.getSplitAppObj().backMaster();
},
onPressGoToMaster : function() {
this.getSplitAppObj().toMaster(this.createId("master2"));
},
onListItemPress : function(oEvent) {
var sToPageId = oEvent.getParameter("listItem").getCustomData()[0].getValue();
this.getSplitAppObj().toDetail(this.createId(sToPageId));
},
onPressModeBtn : function(oEvent) {
var sSplitAppMode = oEvent.getSource().getSelectedButton().getCustomData()[0].getValue();
this.getSplitAppObj().setMode(sSplitAppMode);
MessageToast.show("Split Container mode is changed to: " + sSplitAppMode, {duration: 5000});
},
getSplitAppObj : function() {
var result = this.byId("SplitAppDemo");
if (!result) {
jQuery.sap.log.info("SplitApp object can't be found");
}
return result;
}
});
return CController;
});