How do I apply logic to binding aggregation in order to generate children dynamically
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{ height:90px;width:728px;box-sizing:border-box;
}
I have a table in SAPUI5, which works fine, displaying 5 cells of info.
However, how do I apply logic to this? For example, I sometimes need the 2nd cell to be a sap.m.RatingIndicator
as opposed to sap.m.Text
.
Is there a way to provide logic or must the cells always be hard-coded?
oTable.bindItems("/", new ColumnListItem({
cells: [
new HTML({ // sap/ui/core/HTML
content: "<p style='margin:0'>{path: 'Sequence', type: 'sap.ui.model.odata.type.String', constraints: {isDigitSequence: true}}. {QuestionDesc} - <strong>{CompetencyDesc}</strong></p>"
}),
new Text({ // sap/m/Text
text: "{AnswerLabel} ({AnswerScore})",
visible: true
}),
new Image({ // sap/m/Image
src: "{SmileyUrl}",
width: "2em"
}),
// ...
]
}));
sapui5
add a comment |
I have a table in SAPUI5, which works fine, displaying 5 cells of info.
However, how do I apply logic to this? For example, I sometimes need the 2nd cell to be a sap.m.RatingIndicator
as opposed to sap.m.Text
.
Is there a way to provide logic or must the cells always be hard-coded?
oTable.bindItems("/", new ColumnListItem({
cells: [
new HTML({ // sap/ui/core/HTML
content: "<p style='margin:0'>{path: 'Sequence', type: 'sap.ui.model.odata.type.String', constraints: {isDigitSequence: true}}. {QuestionDesc} - <strong>{CompetencyDesc}</strong></p>"
}),
new Text({ // sap/m/Text
text: "{AnswerLabel} ({AnswerScore})",
visible: true
}),
new Image({ // sap/m/Image
src: "{SmileyUrl}",
width: "2em"
}),
// ...
]
}));
sapui5
add a comment |
I have a table in SAPUI5, which works fine, displaying 5 cells of info.
However, how do I apply logic to this? For example, I sometimes need the 2nd cell to be a sap.m.RatingIndicator
as opposed to sap.m.Text
.
Is there a way to provide logic or must the cells always be hard-coded?
oTable.bindItems("/", new ColumnListItem({
cells: [
new HTML({ // sap/ui/core/HTML
content: "<p style='margin:0'>{path: 'Sequence', type: 'sap.ui.model.odata.type.String', constraints: {isDigitSequence: true}}. {QuestionDesc} - <strong>{CompetencyDesc}</strong></p>"
}),
new Text({ // sap/m/Text
text: "{AnswerLabel} ({AnswerScore})",
visible: true
}),
new Image({ // sap/m/Image
src: "{SmileyUrl}",
width: "2em"
}),
// ...
]
}));
sapui5
I have a table in SAPUI5, which works fine, displaying 5 cells of info.
However, how do I apply logic to this? For example, I sometimes need the 2nd cell to be a sap.m.RatingIndicator
as opposed to sap.m.Text
.
Is there a way to provide logic or must the cells always be hard-coded?
oTable.bindItems("/", new ColumnListItem({
cells: [
new HTML({ // sap/ui/core/HTML
content: "<p style='margin:0'>{path: 'Sequence', type: 'sap.ui.model.odata.type.String', constraints: {isDigitSequence: true}}. {QuestionDesc} - <strong>{CompetencyDesc}</strong></p>"
}),
new Text({ // sap/m/Text
text: "{AnswerLabel} ({AnswerScore})",
visible: true
}),
new Image({ // sap/m/Image
src: "{SmileyUrl}",
width: "2em"
}),
// ...
]
}));
sapui5
sapui5
edited Jan 3 at 13:35


Boghyon Hoffmann
6,69462860
6,69462860
asked Jan 3 at 12:00
Adam HarkusAdam Harkus
373427
373427
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
You can make use of a factory function.
<Table items="{
path: '/',
factory: '.createColumnListItem'
}" />
createColumnListItem: function(id, context/*of the current item*/) {
const displayRatingIndicatorInstead = /*...*/;
return new ColumnListItem(id, {
cells: [
// ...
displayRatingIndicatorInstead ? new RatingIndicator() : new Text(),
// ...
]
});
},
In contrast to providing a template control, factory functions allow us to instantiate a new control dynamically for each iteration step.
For more information and examples, take a look at the documentation topic Using Factory Functions.
When using bindItems
oTable.bindItems({
path: "/",
factory: this.createColumnListItem.bind(this),
// no template!
// ...
});
From the API reference: ManagedObject#bindAggregation
:
A factory function that will be called to create an object for each item in the aggregation; this is an alternative to providing a template object and can be used when the objects should differ depending on the binding context; the factory function will be called with two parameters:
- An
id
that should be used for the created object, and
- The binding
context
for which the object has to be created;
The function must return an object appropriate for the bound aggregation.
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%2f54021891%2fhow-do-i-apply-logic-to-binding-aggregation-in-order-to-generate-children-dynami%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
You can make use of a factory function.
<Table items="{
path: '/',
factory: '.createColumnListItem'
}" />
createColumnListItem: function(id, context/*of the current item*/) {
const displayRatingIndicatorInstead = /*...*/;
return new ColumnListItem(id, {
cells: [
// ...
displayRatingIndicatorInstead ? new RatingIndicator() : new Text(),
// ...
]
});
},
In contrast to providing a template control, factory functions allow us to instantiate a new control dynamically for each iteration step.
For more information and examples, take a look at the documentation topic Using Factory Functions.
When using bindItems
oTable.bindItems({
path: "/",
factory: this.createColumnListItem.bind(this),
// no template!
// ...
});
From the API reference: ManagedObject#bindAggregation
:
A factory function that will be called to create an object for each item in the aggregation; this is an alternative to providing a template object and can be used when the objects should differ depending on the binding context; the factory function will be called with two parameters:
- An
id
that should be used for the created object, and
- The binding
context
for which the object has to be created;
The function must return an object appropriate for the bound aggregation.
add a comment |
You can make use of a factory function.
<Table items="{
path: '/',
factory: '.createColumnListItem'
}" />
createColumnListItem: function(id, context/*of the current item*/) {
const displayRatingIndicatorInstead = /*...*/;
return new ColumnListItem(id, {
cells: [
// ...
displayRatingIndicatorInstead ? new RatingIndicator() : new Text(),
// ...
]
});
},
In contrast to providing a template control, factory functions allow us to instantiate a new control dynamically for each iteration step.
For more information and examples, take a look at the documentation topic Using Factory Functions.
When using bindItems
oTable.bindItems({
path: "/",
factory: this.createColumnListItem.bind(this),
// no template!
// ...
});
From the API reference: ManagedObject#bindAggregation
:
A factory function that will be called to create an object for each item in the aggregation; this is an alternative to providing a template object and can be used when the objects should differ depending on the binding context; the factory function will be called with two parameters:
- An
id
that should be used for the created object, and
- The binding
context
for which the object has to be created;
The function must return an object appropriate for the bound aggregation.
add a comment |
You can make use of a factory function.
<Table items="{
path: '/',
factory: '.createColumnListItem'
}" />
createColumnListItem: function(id, context/*of the current item*/) {
const displayRatingIndicatorInstead = /*...*/;
return new ColumnListItem(id, {
cells: [
// ...
displayRatingIndicatorInstead ? new RatingIndicator() : new Text(),
// ...
]
});
},
In contrast to providing a template control, factory functions allow us to instantiate a new control dynamically for each iteration step.
For more information and examples, take a look at the documentation topic Using Factory Functions.
When using bindItems
oTable.bindItems({
path: "/",
factory: this.createColumnListItem.bind(this),
// no template!
// ...
});
From the API reference: ManagedObject#bindAggregation
:
A factory function that will be called to create an object for each item in the aggregation; this is an alternative to providing a template object and can be used when the objects should differ depending on the binding context; the factory function will be called with two parameters:
- An
id
that should be used for the created object, and
- The binding
context
for which the object has to be created;
The function must return an object appropriate for the bound aggregation.
You can make use of a factory function.
<Table items="{
path: '/',
factory: '.createColumnListItem'
}" />
createColumnListItem: function(id, context/*of the current item*/) {
const displayRatingIndicatorInstead = /*...*/;
return new ColumnListItem(id, {
cells: [
// ...
displayRatingIndicatorInstead ? new RatingIndicator() : new Text(),
// ...
]
});
},
In contrast to providing a template control, factory functions allow us to instantiate a new control dynamically for each iteration step.
For more information and examples, take a look at the documentation topic Using Factory Functions.
When using bindItems
oTable.bindItems({
path: "/",
factory: this.createColumnListItem.bind(this),
// no template!
// ...
});
From the API reference: ManagedObject#bindAggregation
:
A factory function that will be called to create an object for each item in the aggregation; this is an alternative to providing a template object and can be used when the objects should differ depending on the binding context; the factory function will be called with two parameters:
- An
id
that should be used for the created object, and
- The binding
context
for which the object has to be created;
The function must return an object appropriate for the bound aggregation.
edited Mar 24 at 17:44
answered Jan 3 at 13:29


Boghyon HoffmannBoghyon Hoffmann
6,69462860
6,69462860
add a comment |
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.
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%2f54021891%2fhow-do-i-apply-logic-to-binding-aggregation-in-order-to-generate-children-dynami%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