我一般都不熟悉UI5,JS和Web开发。在openSAP上有关SAPUI5的课程之后,我得到了以下页面:
城市名称显示在标签$( function(){$.widget( "custom.combobox", {
_create: function() {
this.wrapper = $( "<span>" )
.addClass( "custom-combobox" )
.insertAfter( this.element );
this.element.hide();
this._createAutocomplete();
},
_createAutocomplete: function() {
var selected = this.element.children( ":selected" ),
value = selected.val() ? selected.text() : "";
this.input = $( "<input>" )
.appendTo( this.wrapper )
.val( value )
.attr( "title", "prodlists" )
.attr( "placeholder", "3 letter minimum")
.attr("style", "width:250px;")
.addClass( "custom-combobox-input ui-widget ui-widget-content ui-state-default ui-corner-left" )
.autocomplete({
delay: 0,
minLength: 3,
source: $.proxy( this, "_source" )
});
this._on( this.input, {
autocompleteselect: function( event, ui ) {
ui.item.option.selected = true;
this._trigger( "select", event, {
item: ui.item.option
});
},
autocompletechange: "_removeIfInvalid"
});
},
_source: function( request, response ) {
var matcher = new RegExp( $.ui.autocomplete.escapeRegex(request.term), "i" );
response( this.element.children( "option" ).map(function() {
var text = $( this ).text();
if ( this.value && ( !request.term || matcher.test(text) ) )
return {
label: text,
value: text,
option: this
};
}) );
},
_removeIfInvalid: function( event, ui ) {
// Selected an item, nothing to do
if ( ui.item ) {
return;
}
// Search for a match (case-insensitive)
var value = this.input.val(),
valueLowerCase = value.toLowerCase(),
valid = false;
this.element.children( "option" ).each(function() {
if ( $( this ).text().toLowerCase() === valueLowerCase ) {
this.selected = valid = true;
return false;
}
});
// Found a match, nothing to do
if ( valid ) {
return;
}
// Remove invalid value
this.input.val( "" );
this.element.val( "" );
this.input.autocomplete( "instance" ).term = "";
},
_destroy: function() {
this.wrapper.remove();
this.element.show();
}
});
中。
如果城市名称为list/secondStatues/ObjectStatues
,我想将其颜色更改为红色。
在这里找到有关的XML视图和controller.js,我从以下地方遇到问题:
"Berlin"
注意:我放<List>
<!-- ... -->
<secondStatus>
<ObjectStatus
title="{i18n>statusDeliveryFrom}"
text="{
parts: [
{
path: 'ToSupplier/Address/City'
}
],
formatter2: '.formatter.cityColor'
}"
/>
</secondStatus>
</List>
是因为还有另一个格式化程序
controller.js示例:
formatter2
答案 0 :(得分:1)
如果是
"Berlin"
,我想将城市的名称颜色变成红色。
<ObjectStatus
state="{= ${ToSupplier/Address/City} === 'Berlin' ? 'Error' : 'None'}"
text="{ToSupplier/Address/City}"
/>
控件sap.m.ObjectStatus
通过属性state
支持语义颜色,该属性等待:
"Error"
(红色)"Warning"
(黄色)"Success"
(绿色) "Information"
(蓝色,自1.60开始可用)
和"None"
。
如果需要其他颜色,请查看this answer。但是,如果要在FLP之类的应用程序容器中使用该应用程序,我强烈建议避免使用自定义CSS。