<!DOCTYPE html>
<html>
<head>
<meta http-equiv="X-UA-Compatible" content="IE=edge"/>
<meta charset="UTF-8">
<title>SplitApp Tree</title>
<script
id="sap-ui-bootstrap"
src='https://sapui5.hana.ondemand.com/resources/sap-ui-core.js'
data-sap-ui-theme="sap_bluecrystal"
data-sap-ui-libs="sap.m,sap.ui.commons,sap.ui.table"
data-sap-ui-xx-bindingSyntax="complex"
data-sap-ui-resourceroots='{
"sap.ui.demo.split": "./"
}'>
</script>
<style>
.labelStyle{
font-size:0.975rem;
margin-top:12%;
}
.inputStyle{
margin-left:6%;
}
.flexStyle{
margin-left: 2%;
}
</style>
<script>
new sap.m.Shell("ShellId",{title: "SplitApp Tree",
showLogout: false,
app: new sap.ui.core.ComponentContainer({
name: "sap.ui.demo.split"
})
}).placeAt("content");
</script>
</head>
<body class="sapUiBody" id="content">
</body>
</html>
// Code goes here
/* Styles go here */
jQuery.sap.declare("sap.ui.demo.split.Component");
sap.ui.core.UIComponent.extend("sap.ui.demo.split.Component", {
createContent : function () {
// create root view
var oView = sap.ui.view({
id : "app",
viewName : "sap.ui.demo.split.SplitHome",
type : "JS",
});
var myData= [{id:"1",name:"Attachment"},
{id:"2",name:"Notes"},
{id:"3",name:"People"}];
var model = new sap.ui.model.json.JSONModel();
model.setData({
modelData: {
userData : []
}
});
oView.setModel(model);
oView.getModel().setProperty("/modelData/Data", myData);
return oView;
}
});
sap.ui.jsview("sap.ui.demo.split.SplitHome", {
/** Specifies the Controller belonging to this View.
* In the case that it is not implemented, or that "null" is returned, this View does not have a Controller.
* @memberOf routingdemo.App
*/
getControllerName : function() {
return "sap.ui.demo.split.SplitHome";
},
/** Is initially called once after the Controller has been instantiated. It is the place where the UI is constructed.
* Since the Controller is given to this method, its event handlers can be attached right away.
* @memberOf routingdemo.App
*/
createContent : function(oController) {
this.setDisplayBlock(true);
this.app = new sap.m.App("mainApp",{initialPage:"SplitPage"});
var page = sap.ui.jsview("SplitPage", "sap.ui.demo.split.SplitPage");
this.app.addPage(page);
return this.app;
}
});
sap.ui.controller("sap.ui.demo.split.SplitHome", {
/**
* Called when a controller is instantiated and its View controls (if available) are already created.
* Can be used to modify the View before it is displayed, to bind event handlers and do other one-time initialization.
* @memberOf zui5_sample.Home
*/
// onInit: function() {
//
// },
/**
* Similar to onAfterRendering, but this hook is invoked before the controller's View is re-rendered
* (NOT before the first rendering! onInit() is used for that one!).
* @memberOf zui5_sample.Home
*/
// onBeforeRendering: function() {
//
// },
/**
* Called when the View has been rendered (so its HTML is part of the document). Post-rendering manipulations of the HTML could be done here.
* This hook is the same one that SAPUI5 controls get after being rendered.
* @memberOf zui5_sample.Home
*/
// onAfterRendering: function() {
//
// },
/**
* Called when the Controller is destroyed. Use this one to free resources and finalize activities.
* @memberOf zui5_sample.Home
*/
// onExit: function() {
//
// }
});
sap.ui.jsview("sap.ui.demo.split.SplitPage", {
/** Specifies the Controller belonging to this View.
* In the case that it is not implemented, or that "null" is returned, this View does not have a Controller.
* @memberOf routingdemo.App
*/
getControllerName : function() {
return "sap.ui.demo.split.SplitPage";
},
/** Is initially called once after the Controller has been instantiated. It is the place where the UI is constructed.
* Since the Controller is given to this method, its event handlers can be attached right away.
* @memberOf routingdemo.App
*/
createContent : function(oController) {
var controller = this.oController;
//Define some sample data
var oData = {
root:{
name: "root",
description: "root description",
checked: false,
0: {
name: "item1",
description: "item1 description",
checked: true,
0: {
name: "subitem1-1",
description: "subitem1-1 description",
checked: true,
0: {
name: "subsubitem1-1-1",
description: "subsubitem1-1-1 description",
checked: true
},
1: {
name: "subsubitem1-1-2",
description: "subsubitem1-1-2 description",
checked: true
}
},
1: {
name: "subitem1-2",
description: "subitem1-2 description",
checked: true,
0: {
name: "subsubitem1-2-1",
description: "subsubitem1-2-1 description",
checked: true
}
}
},
1:{
name: "item2",
description: "item2 description",
checked: true,
0: {
name: "subitem2-1",
description: "subitem2-1 description",
checked: true
}
},
2:{
name: "item3",
description: "item3 description",
checked: true
}
}
};
for (var i = 0; i < 20; i++) {
oData["root"][2][i] = {
name: "subitem3-" + i,
description: "subitem3-" + i + " description",
checked: false
};
}
//Create an instance of the table control
var oTable = new sap.ui.table.TreeTable({
columns: [
new sap.ui.table.Column({label: "Name", template: "name"})
],
selectionMode: sap.ui.table.SelectionMode.Single,
enableColumnReordering: true,
expandFirstLevel: true,
toggleOpenState: function(oEvent) {
var iRowIndex = oEvent.getParameter("rowIndex");
var oRowContext = oEvent.getParameter("rowContext");
var bExpanded = oEvent.getParameter("expanded");
alert("rowIndex: " + iRowIndex +
" - rowContext: " + oRowContext.getPath() +
" - expanded? " + bExpanded);
}
});
//Create a model and bind the table rows to this model
var oModel = new sap.ui.model.json.JSONModel();
oModel.setData(oData);
oTable.setModel(oModel);
oTable.bindRows("/root");
var oSplitApp = new sap.m.SplitApp("oSplitApp");
var oPage1 = new sap.m.Page({title:"Master Details", content:[oTable]});
var oPage2 = new sap.m.Page({title:"Item Details"});
oSplitApp.addMasterPage(oPage1);
oSplitApp.addDetailPage(oPage2);
return oSplitApp;
}
});
sap.ui.controller("sap.ui.demo.split.SplitPage", {
/**
* Called when a controller is instantiated and its View controls (if available) are already created.
* Can be used to modify the View before it is displayed, to bind event handlers and do other one-time initialization.
* @memberOf table_v01.Main
*/
onInit: function() {
},
onPress: function(oEvent){
}
});