SAPUI5 add element on top of a VBox
I am creating ObjectStatus and Text elements in my controller in order to add them into a VBox element in my view. I do this with the addItem method. Every new element is automatically placed on the very bottom of the VBox. How can I achieve that the new element is added on the top of the VBox instead (above the elements I added before)? Thank you for the help!
sapui5
add a comment |
I am creating ObjectStatus and Text elements in my controller in order to add them into a VBox element in my view. I do this with the addItem method. Every new element is automatically placed on the very bottom of the VBox. How can I achieve that the new element is added on the top of the VBox instead (above the elements I added before)? Thank you for the help!
sapui5
Can you select an answer or give more information on what you exactly need. Thanks.
– Matthijs Mennens
Nov 18 at 18:54
add a comment |
I am creating ObjectStatus and Text elements in my controller in order to add them into a VBox element in my view. I do this with the addItem method. Every new element is automatically placed on the very bottom of the VBox. How can I achieve that the new element is added on the top of the VBox instead (above the elements I added before)? Thank you for the help!
sapui5
I am creating ObjectStatus and Text elements in my controller in order to add them into a VBox element in my view. I do this with the addItem method. Every new element is automatically placed on the very bottom of the VBox. How can I achieve that the new element is added on the top of the VBox instead (above the elements I added before)? Thank you for the help!
sapui5
sapui5
asked Nov 15 at 22:35
user5601025
Can you select an answer or give more information on what you exactly need. Thanks.
– Matthijs Mennens
Nov 18 at 18:54
add a comment |
Can you select an answer or give more information on what you exactly need. Thanks.
– Matthijs Mennens
Nov 18 at 18:54
Can you select an answer or give more information on what you exactly need. Thanks.
– Matthijs Mennens
Nov 18 at 18:54
Can you select an answer or give more information on what you exactly need. Thanks.
– Matthijs Mennens
Nov 18 at 18:54
add a comment |
3 Answers
3
active
oldest
votes
You should use:
this.byId("vbox").insertItem(oControl);
instead of:
this.byId("vbox").addItem(oControl);
add a comment |
Set direction
property (inherited from FlexBox) of your VBox
control to ColumnReverse
.
Alternatively, as pointed out by Matthijs, you can use insertItem()
instead of addItem()
. That would also allow precise placement within the aggregation using the iIndex
parameter.
add a comment |
Here's is another suggestion:
- You can get all the items of the VBox in an array.
- Remove items from the VBox
- Place your new item at first position in the VBox.
- Add stored VBox items with from the array.
//Add some items initially to the VBox
for (i = 0; i < 4; i++) {
this.getView().byId("idVBox").addItem(new sap.m.Text({
text: "SomeText2"
}));
}
//Get the items of the Vbox
var array = this.getView().byId("idVBox").getItems();
//remove all items
this.getView().byId("idVBox").removeAllItems();
//add your new item as the first item to the VBox
this.getView().byId("idVBox").addItem(new sap.m.Text({
id: "someOtherid",
text: "SomeText2New"
}));
//add all the others back
for (i = 0; i < array.length; i++)
this.getView().byId("idVBox").addItem(array[i]);
Considering the other options already proposed, this requires a lot of unnecessary code.
– rikusv
Nov 17 at 22:18
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53328832%2fsapui5-add-element-on-top-of-a-vbox%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
3 Answers
3
active
oldest
votes
3 Answers
3
active
oldest
votes
active
oldest
votes
active
oldest
votes
You should use:
this.byId("vbox").insertItem(oControl);
instead of:
this.byId("vbox").addItem(oControl);
add a comment |
You should use:
this.byId("vbox").insertItem(oControl);
instead of:
this.byId("vbox").addItem(oControl);
add a comment |
You should use:
this.byId("vbox").insertItem(oControl);
instead of:
this.byId("vbox").addItem(oControl);
You should use:
this.byId("vbox").insertItem(oControl);
instead of:
this.byId("vbox").addItem(oControl);
answered Nov 16 at 7:15
Matthijs Mennens
1,039216
1,039216
add a comment |
add a comment |
Set direction
property (inherited from FlexBox) of your VBox
control to ColumnReverse
.
Alternatively, as pointed out by Matthijs, you can use insertItem()
instead of addItem()
. That would also allow precise placement within the aggregation using the iIndex
parameter.
add a comment |
Set direction
property (inherited from FlexBox) of your VBox
control to ColumnReverse
.
Alternatively, as pointed out by Matthijs, you can use insertItem()
instead of addItem()
. That would also allow precise placement within the aggregation using the iIndex
parameter.
add a comment |
Set direction
property (inherited from FlexBox) of your VBox
control to ColumnReverse
.
Alternatively, as pointed out by Matthijs, you can use insertItem()
instead of addItem()
. That would also allow precise placement within the aggregation using the iIndex
parameter.
Set direction
property (inherited from FlexBox) of your VBox
control to ColumnReverse
.
Alternatively, as pointed out by Matthijs, you can use insertItem()
instead of addItem()
. That would also allow precise placement within the aggregation using the iIndex
parameter.
edited Nov 16 at 8:29
answered Nov 16 at 6:40
rikusv
30015
30015
add a comment |
add a comment |
Here's is another suggestion:
- You can get all the items of the VBox in an array.
- Remove items from the VBox
- Place your new item at first position in the VBox.
- Add stored VBox items with from the array.
//Add some items initially to the VBox
for (i = 0; i < 4; i++) {
this.getView().byId("idVBox").addItem(new sap.m.Text({
text: "SomeText2"
}));
}
//Get the items of the Vbox
var array = this.getView().byId("idVBox").getItems();
//remove all items
this.getView().byId("idVBox").removeAllItems();
//add your new item as the first item to the VBox
this.getView().byId("idVBox").addItem(new sap.m.Text({
id: "someOtherid",
text: "SomeText2New"
}));
//add all the others back
for (i = 0; i < array.length; i++)
this.getView().byId("idVBox").addItem(array[i]);
Considering the other options already proposed, this requires a lot of unnecessary code.
– rikusv
Nov 17 at 22:18
add a comment |
Here's is another suggestion:
- You can get all the items of the VBox in an array.
- Remove items from the VBox
- Place your new item at first position in the VBox.
- Add stored VBox items with from the array.
//Add some items initially to the VBox
for (i = 0; i < 4; i++) {
this.getView().byId("idVBox").addItem(new sap.m.Text({
text: "SomeText2"
}));
}
//Get the items of the Vbox
var array = this.getView().byId("idVBox").getItems();
//remove all items
this.getView().byId("idVBox").removeAllItems();
//add your new item as the first item to the VBox
this.getView().byId("idVBox").addItem(new sap.m.Text({
id: "someOtherid",
text: "SomeText2New"
}));
//add all the others back
for (i = 0; i < array.length; i++)
this.getView().byId("idVBox").addItem(array[i]);
Considering the other options already proposed, this requires a lot of unnecessary code.
– rikusv
Nov 17 at 22:18
add a comment |
Here's is another suggestion:
- You can get all the items of the VBox in an array.
- Remove items from the VBox
- Place your new item at first position in the VBox.
- Add stored VBox items with from the array.
//Add some items initially to the VBox
for (i = 0; i < 4; i++) {
this.getView().byId("idVBox").addItem(new sap.m.Text({
text: "SomeText2"
}));
}
//Get the items of the Vbox
var array = this.getView().byId("idVBox").getItems();
//remove all items
this.getView().byId("idVBox").removeAllItems();
//add your new item as the first item to the VBox
this.getView().byId("idVBox").addItem(new sap.m.Text({
id: "someOtherid",
text: "SomeText2New"
}));
//add all the others back
for (i = 0; i < array.length; i++)
this.getView().byId("idVBox").addItem(array[i]);
Here's is another suggestion:
- You can get all the items of the VBox in an array.
- Remove items from the VBox
- Place your new item at first position in the VBox.
- Add stored VBox items with from the array.
//Add some items initially to the VBox
for (i = 0; i < 4; i++) {
this.getView().byId("idVBox").addItem(new sap.m.Text({
text: "SomeText2"
}));
}
//Get the items of the Vbox
var array = this.getView().byId("idVBox").getItems();
//remove all items
this.getView().byId("idVBox").removeAllItems();
//add your new item as the first item to the VBox
this.getView().byId("idVBox").addItem(new sap.m.Text({
id: "someOtherid",
text: "SomeText2New"
}));
//add all the others back
for (i = 0; i < array.length; i++)
this.getView().byId("idVBox").addItem(array[i]);
//Add some items initially to the VBox
for (i = 0; i < 4; i++) {
this.getView().byId("idVBox").addItem(new sap.m.Text({
text: "SomeText2"
}));
}
//Get the items of the Vbox
var array = this.getView().byId("idVBox").getItems();
//remove all items
this.getView().byId("idVBox").removeAllItems();
//add your new item as the first item to the VBox
this.getView().byId("idVBox").addItem(new sap.m.Text({
id: "someOtherid",
text: "SomeText2New"
}));
//add all the others back
for (i = 0; i < array.length; i++)
this.getView().byId("idVBox").addItem(array[i]);
//Add some items initially to the VBox
for (i = 0; i < 4; i++) {
this.getView().byId("idVBox").addItem(new sap.m.Text({
text: "SomeText2"
}));
}
//Get the items of the Vbox
var array = this.getView().byId("idVBox").getItems();
//remove all items
this.getView().byId("idVBox").removeAllItems();
//add your new item as the first item to the VBox
this.getView().byId("idVBox").addItem(new sap.m.Text({
id: "someOtherid",
text: "SomeText2New"
}));
//add all the others back
for (i = 0; i < array.length; i++)
this.getView().byId("idVBox").addItem(array[i]);
edited Nov 16 at 12:33
answered Nov 16 at 9:07
Nandan Chaturvedi
597622
597622
Considering the other options already proposed, this requires a lot of unnecessary code.
– rikusv
Nov 17 at 22:18
add a comment |
Considering the other options already proposed, this requires a lot of unnecessary code.
– rikusv
Nov 17 at 22:18
Considering the other options already proposed, this requires a lot of unnecessary code.
– rikusv
Nov 17 at 22:18
Considering the other options already proposed, this requires a lot of unnecessary code.
– rikusv
Nov 17 at 22:18
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53328832%2fsapui5-add-element-on-top-of-a-vbox%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Can you select an answer or give more information on what you exactly need. Thanks.
– Matthijs Mennens
Nov 18 at 18:54