on 10-15-2018 4:37 PM
I get the combo box items based on Odata entity set. In the same set, I have RGB values for each record and a name column. In the combox box , I need to show this name column as drop down with background color based on its corresponding RGB values.
RGB values are not fixed, they vary based on the backend data.
How to achieve this.
Hello,
you can only achieve this with CSS.
First you need an event delegate for the onAfterRendering event:
var yourComboBox = this.getView().byId("<your id from the XML view>");
if (yourComboBox.aDelegates.length == 0) {
// only add event delegate once
yourComboBox.addEventDelegate({
onAfterRendering: this.onAfterRendering.bind(this)
});
}
Then you can implement the function on your controller:
onAfterRendering: function (obj) {
var yourComboBox = obj.srcControl;
// here you need to determine the id from the html dom element
// you can use yourComboBox.getId() to achieve this
// change the css by using jQuery:
$(yourId).css(....);
}
Hope this helps.
Andre
If anyone knows a more elegant solution to limit the event delegation to 1, please let me know.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
have you tried adding this as a css class so the color can update automatically based on the odata value and a css class?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
86 | |
10 | |
10 | |
9 | |
7 | |
7 | |
6 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.