function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
sp13sp13 

compare list or string values to table cell value in visualforce page

hi,
i need to compare the values of list in my apex class to the table cell values in visualforce page.
class:
public List<Seat__c> getAllSeats() {
        return[SELECT Name, taken__c, pending__c FROM Seat__c WHERE Schedule__c = 'a0590000007O6Lu'];
}
vf page:
<table width="500" border="1">
          <apex:variable value="{!AllSeats}" var="r">
                     <tr height="30">  
                                <td width="10%"></td>
                                <td width="5%"> PWD </td>
                                <td width="5%" style="background-color:{!If(r.Name=='1' && r.Taken__c==true,'red',If(r.Name=='1' && r.Pending__c==true,'pink',''))};">
                                  1
                                </td>
                                <td width="5%" style="background-color:{!If(r.Name=='5' && r.Taken__c==true,'red',If(r.Name=='5' && r.Pending__c==true,'pink',''))};">
                                  5
                                </td>
                                <td width="5%" style="background-color:{!If(r.Name=='9' && r.Taken__c==true,'red',If(r.Name=='9' && r.Pending__c==true,'pink',''))};">
                                  9
                                </td>
                                .........
                     </tr>
          </apex:variable>
</table>

the table looks like this:
User-added image

i tried the table cell condition in apex:pageblocktable and it worked fine.
but it didn't work in table tr td
the "AllSeats" values return this values:
User-added image
User-added image
so, the table cell #6 should be color red, and #5 should be pink..
instead it displayed this error:
"Unknown property 'VisualforceArrayList.Name'
Error is in expression '{!If(r.Name=='1' && r.Taken__c==true,'red',If(r.Name=='1' && r.Pending__c==true,'pink',''))}' in component <apex:variable> in page
"

help please.
Ashish_SFDCAshish_SFDC
Hi , 


See the below link, there is related code which you may customize, 

http://salesforce.stackexchange.com/questions/31380/highlight-single-selected-row-in-table

https://developer.salesforce.com/forums?id=906F000000097oYIAQ

http://stackoverflow.com/questions/19861124/conditionally-change-color-apex-visualforce

http://salesforce.stackexchange.com/questions/32853/can-i-change-the-color-of-a-vf-table-cell-dynamically


Regards,
Ashish