我正在尝试根据运营商对象上“Team__c”字段中的 ID 是否与用户列表中的任何 ID 匹配来更改列表中值的颜色。我的控制器一次返回颜色,此颜色适用于所有记录(请参阅调试日志)。列表中的所有值都是蓝色的,有些应该是红色的。先感谢您。
Visualforce 代码:::
<apex:pageblocktable value="{!carriers}" var="c">
<apex:column headervalue="Carrier">
<font color="{!color2}">
<apex:outputtext value="{!c.name}"/>
</font>
</apex:column>
控制器:::
public string getcolor2() {
list<carrier__c> carriers = [select team__c from carrier__c where team__c != NULL];
list<user> users= new list<user>();
users = [select id from user where userrole.name = 'Executive'];
set<string> uid = new set<string>();
for(user us: users){
uid.add(us.id);
}
string color = 'red';
for(carrier__c car: carriers){
system.debug('*****List of carriers: ' + carriers);
system.debug('*****List of users: ' + uid);
system.debug('*****Current carrier= '+car);
if(uid.contains(car.team__c) ){
color='blue';
system.debug('***** Set color to:'+color);
}
}
system.debug('***** Returning color: ' + color);
return color;
}
调试日志::::
*****List of carriers: (Carrier__c:{Team__c=005U0000001D3E5IAK, Id=a0HJ0000003bl8nMAA}, Carrier__c:{Team__c=005J0000001EEIHIA4, Id=a0HJ0000003bitnMAA}, Carrier__c:{Team__c=005U0000001BHRKIA4, Id=a0HJ0000003eD64MAE})
*****List of users: {005U0000001D3E5IAK}
*****Current carrier= Carrier__c:{Team__c=005U0000001D3E5IAK, Id=a0HJ0000003bl8nMAA}
***** Set color to:blue
*****List of users: {005U0000001D3E5IAK}
*****Current carrier= Carrier__c:{Team__c=005J0000001EEIHIA4, Id=a0HJ0000003bitnMAA}
*****List of users: {005U0000001D3E5IAK}
*****Current carrier= Carrier__c:{Team__c=005U0000001BHRKIA4, Id=a0HJ0000003eD64MAE}
***** Returning color: blue