You need to sign in to do that
Don't have an account?
sp13
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:
the table looks like this:
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:
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.
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:
return[SELECT Name, taken__c, pending__c FROM Seat__c WHERE Schedule__c = 'a0590000007O6Lu'];
}
<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>
<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:
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:
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.
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