sample.controller.js:
sap.ui.controller("sample.sample", {
sample:function(){
var oTable= sap.ui.getCore().byId("mytable");
oTable.addColumn(new sap.ui.table.Column({
id:"ot",
label: new sap.ui.commons.Label({text: "status"}),
template: new sap.ui.commons.TextView({text:{path:"status",formatter:function(status)
{
if(status==1)
{
return true
}
else if (status==0)
{
return false
}
}}})
}));
}
});
sample.view.js:
sap.ui.jsview("sample.sample", {
getControllerName : function() {
return "sample.sample";
},
createContent : function(oController) {
var data = [
{lastName: "Dente", Name: "Al",status:1},
{lastName: "Friese", Name: "Andy",status:0},
{lastName: "Mann", Name: "Anita",status:1}
];
var oModel = new sap.ui.model.json.JSONModel();
oModel.setData(data);
var oTable = new sap.ui.table.Table({
id:"mytable",
visibleRowCount: 3,
width : "85%"
});
oTable.addColumn(new sap.ui.table.Column({
label: new sap.ui.commons.Label({text: "lastName"}),
template: new sap.ui.commons.TextView({text:"{lastName}"})
}));
oTable.addColumn(new sap.ui.table.Column({
label: new sap.ui.commons.Label({text: "Name"}),
template: new sap.ui.commons.TextView({text:"{Name}"})
}));
oTable.setModel(oModel);
oTable.bindRows("/");
var btn =new sap.m.Button({
text:"button1",
press:oController.sample
});
var btn1 =new sap.m.Button({
text:"button2",
press:function(){
oTable.removeColumn(sap.ui.getCore().byId("ot") );
}
});
var oHBox1 = new sap.m.HBox({
items:[
oTable,
btn,btn1,
]
});
var oModel = new sap.ui.model.json.JSONModel({
businessData : [
{Country :"Canada",revenue:410.87,profit:-141.25, population:34789000},
{Country :"China",revenue:338.29,profit:133.82, population:1339724852},
{Country :"France",revenue:487.66,profit:348.76, population:65350000},
{Country :"Germany",revenue:470.23,profit:217.29, population:81799600},
{Country :"India",revenue:170.93,profit:117.00, population:1210193422},
{Country :"United States",revenue:905.08,profit:609.16, population:313490000}
]
});
var oDataset = new sap.viz.ui5.data.FlattenedDataset({
dimensions : [
{
axis : 1,
name : 'Country',
value : "{Country}"
}
],
measures : [
{
name : 'Profit',
value : '{profit}'
},
{
name : 'Revenue',
value : '{revenue}'
}
],
data : {
path : "/businessData"
}
});
var oBarChart = new sap.viz.ui5.Bar({
width : "80%",
height : "400px",
plotArea : {
},
title : {
visible : true,
text : 'Profit and Revenue By Country'
},
dataset : oDataset
});
oBarChart.setModel(oModel);
var oVBox2 = new sap.m.VBox("Vbox2", {
items:[
oBarChart
]
});
return new sap.m.Page({
title: "Title",
content: [
oHBox1,oVBox2
]
});
}
});
sap.ui.controller("sample.sample", {
sample:function(){
var oTable= sap.ui.getCore().byId("mytable");
oTable.addColumn(new sap.ui.table.Column({
id:"ot",
label: new sap.ui.commons.Label({text: "status"}),
template: new sap.ui.commons.TextView({text:{path:"status",formatter:function(status)
{
if(status==1)
{
return true
}
else if (status==0)
{
return false
}
}}})
}));
}
});
sample.view.js:
sap.ui.jsview("sample.sample", {
getControllerName : function() {
return "sample.sample";
},
createContent : function(oController) {
var data = [
{lastName: "Dente", Name: "Al",status:1},
{lastName: "Friese", Name: "Andy",status:0},
{lastName: "Mann", Name: "Anita",status:1}
];
var oModel = new sap.ui.model.json.JSONModel();
oModel.setData(data);
var oTable = new sap.ui.table.Table({
id:"mytable",
visibleRowCount: 3,
width : "85%"
});
oTable.addColumn(new sap.ui.table.Column({
label: new sap.ui.commons.Label({text: "lastName"}),
template: new sap.ui.commons.TextView({text:"{lastName}"})
}));
oTable.addColumn(new sap.ui.table.Column({
label: new sap.ui.commons.Label({text: "Name"}),
template: new sap.ui.commons.TextView({text:"{Name}"})
}));
oTable.setModel(oModel);
oTable.bindRows("/");
var btn =new sap.m.Button({
text:"button1",
press:oController.sample
});
var btn1 =new sap.m.Button({
text:"button2",
press:function(){
oTable.removeColumn(sap.ui.getCore().byId("ot") );
}
});
var oHBox1 = new sap.m.HBox({
items:[
oTable,
btn,btn1,
]
});
var oModel = new sap.ui.model.json.JSONModel({
businessData : [
{Country :"Canada",revenue:410.87,profit:-141.25, population:34789000},
{Country :"China",revenue:338.29,profit:133.82, population:1339724852},
{Country :"France",revenue:487.66,profit:348.76, population:65350000},
{Country :"Germany",revenue:470.23,profit:217.29, population:81799600},
{Country :"India",revenue:170.93,profit:117.00, population:1210193422},
{Country :"United States",revenue:905.08,profit:609.16, population:313490000}
]
});
var oDataset = new sap.viz.ui5.data.FlattenedDataset({
dimensions : [
{
axis : 1,
name : 'Country',
value : "{Country}"
}
],
measures : [
{
name : 'Profit',
value : '{profit}'
},
{
name : 'Revenue',
value : '{revenue}'
}
],
data : {
path : "/businessData"
}
});
var oBarChart = new sap.viz.ui5.Bar({
width : "80%",
height : "400px",
plotArea : {
},
title : {
visible : true,
text : 'Profit and Revenue By Country'
},
dataset : oDataset
});
oBarChart.setModel(oModel);
var oVBox2 = new sap.m.VBox("Vbox2", {
items:[
oBarChart
]
});
return new sap.m.Page({
title: "Title",
content: [
oHBox1,oVBox2
]
});
}
});
index.html:
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta http-equiv='Content-Type' content='text/html;charset=UTF-8'/>
<script src="resources/sap-ui-core.js"
id="sap-ui-bootstrap"
data-sap-ui-libs="sap.m,sap.viz,sap.ui.layout,sap.ui.table,sap.ui.commons"
data-sap-ui-theme="sap_bluecrystal">
</script>
<!-- only load the mobile lib "sap.m" and the "sap_bluecrystal" theme -->
<script>
sap.ui.localResources("sample");
var app = new sap.m.App({initialPage:"idsample1"});
var page = sap.ui.view({id:"idsample1", viewName:"sample.sample", type:sap.ui.core.mvc.ViewType.JS});
app.addPage(page);
app.placeAt("content");
</script>
</head>
<body class="sapUiBody" role="application">
<div id="content"></div>
</body>
</html>
output:
No comments:
Post a Comment