<!-- View -->
<mvc:View controllerName="customControl.controller.Home" xmlns:html="http://www.w3.org/1999/xhtml" xmlns:mvc="sap.ui.core.mvc"
displayBlock="true" xmlns="sap.m">
<App>
<pages>
<Page title="{i18n>title}" id="VBox">
<content>
</content>
</Page>
</pages>
</App>
</mvc:View>
sap.ui.define([
"sap/ui/core/mvc/Controller",
], function(Controller {
"use strict";
return Controller.extend("customControl.controller.Home", {
onInit : function(){
// creating a vbox with label into it
var Box = new sap.m.VBox({
width : "10rem",
items : new sap.m.Label({text: "hello"})
});
// placing it into our view
this.getView().byId("VBox").addContent(Box);
}
});
});
sap.ui.define([
"sap/m/VBox"
], function(VBox) {
"use strict";
return VBox.extend("customVBox", {
metadata: {
properties : {
"backgroundColor" : "sap.ui.core.CSSColor"
}
},
onAfterRendering : function() {
// make sure that onAfterRendering function in VBox is not overwritten
if (VBox.prototype.onAfterRendering) {
VBox.prototype.onAfterRendering.apply(this, arguments);
}
if (this.getBackgroundColor()) {
this.$().css("background-color", this.getBackgroundColor());
}
},
renderer: { }
});
});
sap.ui.define([
"sap/ui/core/mvc/Controller",
//calling the custom control from a folderinside project say control , giving its file name
"customControl/control/customVBox"
], function(Controller, customVBox) {
"use strict";
return Controller.extend("customControl.controller.Home", {
onInit: function() {
var Box = new customVBox({
width: "10rem",
backgroundColor: "yellow",
items: [
new sap.m.Text({
text: "hello"
})
]
});
this.getView().byId("VBox").addContent(Box);
}
});
});
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
21 | |
16 | |
13 | |
12 | |
11 | |
10 | |
7 | |
7 | |
7 | |
7 |