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
Joe HayesJoe Hayes 

apex:dataTable rendered attribute to filter certain results

Hi,

I am comiling a visualforce page at the moment that displays a certain related lists on a custom object.
What I need to do is only display results (rows) where the status__c field equals "booked". This status field is a picklist field with "booked", "transferred" and "cancelled" values.

I have tried the rendered attribute rendered {!status__c} = "booked" but cannot seem to get it to work.

Please can someone have a look at my code below and give me a hand.
<apex:pageBlock title="Delegates">
    <apex:dataTable value="{!Courses__c.Delegates__r}" var="item" border="1" cellpadding="5" cellspacing="1">
       <apex:column style="width:20%">
          <apex:facet name="header">Name</apex:facet>
                {!item.Name}
       </apex:column>
       <apex:column style="width:30%">
          <apex:facet name="header">Signature</apex:facet>
       </apex:column>
       <apex:column style="width:20%">
          <apex:facet name="header">Company Name</apex:facet>
                {!item.Contact__r.Account.Name}
       </apex:column>       
       <apex:column style="width:30%">
          <apex:facet name="header">Email Address</apex:facet>
       </apex:column>       
       <apex:column >
          <apex:facet name="header">Exam Board</apex:facet>
                {!item.Exam_Board__c}
       </apex:column>
        <apex:column >
          <apex:facet name="header">Number of Days</apex:facet>
                <table border="1" cellpadding="5" cellspacing="0">
                <td>1</td>
                <td>2</td>
                <td>3</td>
                <td>4</td>
                <td>5</td>
                </table>
       </apex:column>
    </apex:dataTable>
    </apex:pageBlock>
Thanks very much
Best Answer chosen by Joe Hayes
Rajiv Penagonda 12Rajiv Penagonda 12
You need to use attribute 
rendered="{!item.status__c == 'booked'}"

for all the apex:column elements.

All Answers

Rajiv Penagonda 12Rajiv Penagonda 12
You need to use attribute 
rendered="{!item.status__c == 'booked'}"

for all the apex:column elements.
This was selected as the best answer
Mahesh DMahesh D
Hi Joe,

Please use the below code:
 
rendered="{!IF(item.Status__c = 'booked',true,false)}"

Please do let me know if it helps.

Regards,
Mahesh
Joe HayesJoe Hayes
Thank you guys,

Both of those work perfectly!