Skip to Content
0

SAPUI5 - Hide/Expand Master view in Split APP

Jan 19, 2017 at 02:08 PM

968

avatar image

Hi,

I am following this example to expand/hide the master view and put the details view in fullscreen. The example is this one http://embed.plnkr.co/LLgqgaXWoTAFdykVLNPV/.

index.html in the example

<script>
var app = new sap.m.SplitApp("oSplitApp",{mode:"StretchCompressMode"});
var oMasterPage = sap.ui.xmlview({id:"master", viewName:"home.MasterPage"});
app.addMasterPage(oMasterPage);
var oDetailPage = sap.ui.xmlview({id:"detail", viewName:"home.DetailPage"});
app.addDetailPage(oDetailPage);
app.placeAt("content");
</script>

controller.js in the example

onPress2 : function(){
  var oSplitContainer = sap.ui.getCore().byId("oSplitApp");
  oSplitContainer.setMode(sap.m.SplitAppMode.StretchCompressMode);
  if(oSplitContainer.isMasterShown()){
 oSplitContainer.setMode(sap.m.SplitAppMode.HideMode);
}

My code is slightly different and it does not work.

my App.view.xml as starting view

<mvc:View controllerName="Stora1.view.App" xmlns:mvc="sap.ui.core.mvc" displayBlock="true" xmlns="sap.m">
<SplitApp id="idAppControl" mode="StretchCompressMode" />
</mvc:View>

my index.html

<script>
sap.ui.getCore().attachInit(function() {
new sap.m.Shell({
app: new sap.ui.core.ComponentContainer({
height : "100%",
name : "Stora1"
}),
}).placeAt("content");
});
</script>

my controller.js for the master screen

 onCollapseExpandPress : function(){
  var oSplitContainer = sap.ui.getCore().byId("idAppControl");
  oSplitContainer.setMode(sap.m.SplitAppMode.StretchCompressMode);
  if(oSplitContainer.isMasterShown()){
 oSplitContainer.setMode(sap.m.SplitAppMode.HideMode);
}},

In the controller it complains about the idAppControl. Can anyone suggest what I need to do?

Thanks,

Tim

10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

1 Answer

Sai Vellanki Jan 19, 2017 at 02:26 PM
0

Hello Tim,

Can you try:

var oSplitContainer = this.getView().byId("idAppControl");

Best Regards,

Sai.

Show 1 Share
10 |10000 characters needed characters left characters exceeded

Thank you for your reply, unfortunately, the result is the same.

The error message below:

Master.controller.js:138 Uncaught TypeError: Cannot read property 'setMode' of undefined

this is because oSplitContainer is not defined. Any other ideas?

Thanks,

Tim

0